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
CSS style rule syntax style is the basic unit of ...
example: <html> <head> <style type...
Table of contents 1. The concept of process and t...
apache: create virtual host based on port Take cr...
How to host two or more sites on the popular and ...
Maybe you are using include files here, which is u...
MySQL-Group-Replication is a new feature develope...
I call this kind of bug a typical "Hamlet&qu...
Table of contents Preface 1. Routing lazy loading...
To be honest, this question involves a lot of cor...
This article shares the specific code of JS to ac...
The traditional method is to write a square in a ...
Preface Under the influence of some CSS interacti...
Several concepts Line box: A box that wraps an in...
1. Command Introduction The contab (cron table) c...