Official Website Layui Table Demo page: http://www.layui.com/demo/table.html
Sample screenshot:
Page introduces Layui.css, layui.js
<div id= "ptable" style= "width:1200px;" >
<table class= "layui-table" id= "layui_table_id" lay-filter= "Test" >
</table>
<div ID = "Laypage" ></div>
</div>
=================== Front desk js===================
var limitcount = 10;
var curnum = 1; List Query method function ProductSearch (productgroupid,start,limitsize) {layui.use (' table ', ' laypage ', ' laydate '), fun Ction () {var table = layui.table, laydate=layui.laydate, laypage = Layui.laypa
Ge Table.render ({elem: ' #layui_table_id ', url: ' <%=path%>/xx/plistquery.html?pid= ' +PR Oductgroupid+ ' ¤tpage= ' + start+ ' ¤tnumber= ' + limitsize/*, where:{pagename:start,pagelimit:limitsize}//reference *
/, cols: [[{field: ' ProductId ', title: ' ID ', Width: ' 170 ', sort:true} , {field: ' ProductName ', title: ' Name ', Width: ' 450 '}, {field: ' Productstate ', title: ' State ', Widt H: ' m '}, {field: ' Effecttime ', title: ' Effective Time ', Width: ' A ', sort:true}, {Fiel D: ' Invalidtime ', title: ' Expiration Time ', Width: ' Sort:true ',}, {fieLD: ' Productcost ', title: ' Cost ', Width: ' m ', sort:true}, {field: ' Poperation ', title: ' Operation ', Width:
' m ', fixed: ' Right ', toolbar: ' #barDemo '}], Page:false, height:430
, Done:function (res, Curr, count) {//If the method is asynchronous request data, RES is the information returned by your interface.
If the method is directly assigned, RES is: {data: [], count:99} data is the current page, count is the total length of the data Laypage.render ({ Elem: ' Laypage ', Count:count, curr:curnum, limit : Limitcount, layout: [' prev ', ' page ', ' Next ', ' Skip ', ' count ', ' limit '], Jum
P:function (Obj,first) {if (!first) {curnum = Obj.curr;
Limitcount = Obj.limit;
Console.log ("Curnum" +curnum); //Console.log ("Limitcount" +limitcount);
Layer.msg (curnum+ "-" +limitcount);
ProductSearch (Productgroupid,curnum,limitcount); }}})//Listening tool bar Tabl E.ON (' Tool (test) ', function (obj) {//Note: Tool is the toolbar event name, test is the property of the table original container lay-filter= ' corresponding value ' var data = Obj.data Gets the current row data, layevent = obj.event;
Obtain lay-event corresponding value if (layevent = = ' Detail ') {viewlableinfo (Data.attrid);
Layer.msg (Data.attrid);
else if (layevent = = ' del ') {layer.msg (' delete ');
else if (layevent = = ' edit ') {layer.msg (' editing operation ');
}
});
General usage Laydate.render ({elem: ' #createDate '});
General usage Laydate.render ({elem: ' #processingTime '});
});
var pId = ' ${pgbean.pgid} '; ProductSearch (PId, Curnum, Limitcount);
=================== Business Logic Layer ===================
@Override public String querylist (HttpServletRequest request) {string total = "";
String pid = request.getparameter ("pid");
int currentnumber = Integer.parseint (Request.getparameter ("Currentnumber")); String currentpage = Request.getparameter ("currentpage") = = null?
"1": Request.getparameter ("currentpage");
Pagination processing, showing the first page of 30 data (default) Pagehelper.startpage (Integer.parseint (currentpage), currentnumber);
list<pexl> list = Exportdao.querylist (pId);
if (list.size () > 0) {total = List.get (0). Gettotal ();
Page page = PageHelper.localPage.get ();
if (page!=null) {page.setcurrentpage (Integer.parseint (currentpage));
} pagehelper.endpage ();
Jsonobject jsonobject = new Jsonobject ();
Jsonobject.put ("code", 0);
Jsonobject.put ("msg", "");
Jsonobject.put ("Count", total);
Jsonobject.put ("Data", list); System.out.println ("JSON:----" + jsonobject.tostring ());
return jsonobject.tostring (); }
=================== "SQL" ===================
Where SQL can be written when calculating totals Totle
COUNT (*) over (PARTITION to 1) as Total