I recently made a file system and found that there are too many fields Multi-condition query with paging (paging requires backend paging, and the page can only be passed to the backend to be implemented, and the frontend cannot be implemented directly) When we click the search button, the relevant data of the input value will be filtered out. Multi-condition query is based on the data. After the data is queried, the conditions are opened to make a certain value under the queried data equal to the value entered by the user when the value entered by the user is not empty. Then the queried data is returned to the view and the rendered table is reloaded. The queried data is the filtered data related to the value entered by the user. Multiple condition query form <form class="layui-form" action=""> <div class="layui-inline"> <label class="layui-form-label">Grade</label> <div class="layui-input-inline"> <input type="text" id="grade" name="grade" placeholder="Please select grade" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-inline"> <label class="layui-form-label">Professional</label> <div class="layui-input-inline"> <select name="majorid" id="majorid"> <option value="">Please select</option> </select> </div> </div> <div class="layui-inline"> <div class="layui-input-inline"> <button class="layui-btn" id="searchBtn" lay-submit lay-filter="formDemo" data-type="reload" style="margin-left: 15px"> <i class="layui-icon layui-icon-search"></i> Search </button> <button type="reset" class="layui-btn layui-btn-primary">Reset</button> </div> </div> </form> Use the year calendar to select grade and dynamically obtain major options //Grade displayed in calendar var laydate = layui.laydate; laydate.render({ elem : '#grade', //Specify element type : 'year' }); //Get the drop-down box professional $.ajax({ url : '../../MajorFindAllServlet?deptid=5', dataType : 'json', data : { 'state' : 0 }, //Query all institution types with normal status type : 'post', success : function(data) { $.each(data, function(index, item) { $('#majorid').append( new Option(item.majorname, item.majorid)); // Add elements to the drop-down menu }); layui.form.render("select"); } }); All js are included in..., table is the data table, laydata is the calendar, form is the form, just write which part you need, for details, see Layui official website layui.use(['table', 'laydate', 'form' ], function() {...} Generate table //Generate table var table = layui.table; table.render({ elem : '#table', url : '../../ClassesFindByPageServlet', toolbar : '#toolbarDemo', title: 'Class table', //Export file name page: { layout:['count','prev','page','next', 'skip'] }, //Open paging id: 'tableAll', where : { majorid: '', grade : '' }, request : { 'limitName' : 'pageSize' //Change the default field of the number of entries per page to pageSize }, cellMinWidth : 80, //Globally define the minimum width of regular cells, LayUI 2.2.1 added cols : [ [ { type : 'checkbox', fixed : 'left' }, { field : 'classid', title: 'Class number' }, { field : 'classname', title: 'Class name' }, { field : 'deptname', title : 'Department Name' }, { field : 'majorname', title : 'Professional name' }, { field : 'grade', title: 'Grade', sort : true }, { fixed : 'right', title : 'Operation', toolbar : '#barDemo' } ] ] }); Click submit to reload the form for multiple conditional queries //Click the query button to reload the table $('#searchBtn').on('click', function() { table.reload('tableAll', { method : 'post', where : { grade : $('#grade').val(), majorid : $('#majorid').val() }, page : { curr : 1 } }); return false; }); This concludes this article about the sample code for implementing multi-condition query in Layui. For more information about multi-condition query in Layui, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: How to set focus on HTML elements
>>: CSS3 uses transform deformation combined with events to complete fan-shaped navigation
Recently, Oracle announced the public availabilit...
1. Download the corresponding installation file f...
Two ways to navigate the page Declarative navigat...
Table of contents Preface Instruction Basics Hook...
Recently, I found that the company's server t...
Usage Environment In cmd mode, enter mysql --vers...
This article shares with you two methods of setti...
The development of Docker technology provides a m...
To put it simply, MySQL worm replication is to co...
This article is used to record the installation o...
Redux is a data state management plug-in. When us...
This article example shares the specific code of ...
1. IE8's getElementById only supports id, not ...
There are some issues that are not limited to Vue...
Html code: Copy code The code is as follows: <t...