Front desk
<div id= "DG" ></div>
Js
$ (function () {$ (' #dg '). DataGrid ({height: ' 400px ', Pagenumber:1,title: ' Log list ', pagelist:[10,20,30,40,50],striped: True, Pagination:true,rownumbers:true, Singleselect:true,method: ' POST ', url: '/loginfo/getloglist ', loadmsg: ' Data loading Please later ... ', onbeforeload:function (param) {param.falg = new Date (); },columns: [[{field: ' title ', Title: ' title ', Width:300,align: ' Left '}, {field: ' Type ', tit Le: ' type ', width:100,align: ' Center '}, {field: ' IP ', title: ' IP ', width:200,align: ' Center '}, {field: ' Requesturl ', title: ' Request Address ', Width:100,align: ' Left '}, {field: ' Remark ', title: ' Operation Info ', width : 100,align: ' Left '}, {field: ' OperationID ', title: ' operator ', width:100,align: ' Center '}, {F Ield: ' Operationtime ', title: ' Operation Time ', Width:100,align: ' Center '}]});//Set paging control var p = $ (' #dg '). DataGrid (' Getpager '); $ (P). Pagination ({pagesize:10,//shows the number of record bars per page, by default, Beforepagetext: ' First ',///Page text box to display the Chinese characters afterpagetext: ' pages total {pages} page ', displaymsg: ' Current display {from}-{to} record total} record ', /*onbeforerefresh:function () {$ (this). Pagination (' loading '); Alert (' before Refresh '); $ (this). Pagination (' loaded '); }*/ }); });
Action
public void Getloglist () {int page = getparatoint ("page"); int rows = Getparatoint ("Rows"); Iloginfo loginfobusiness = Busin Essfactory.createloginfobusiness (); page<loginfo> loginfo = loginfobusiness.getpagelist (page, rows, "", New Arraylist<object> ()); RenderJson (" {\ "total\": "+loginfo.gettotalrow () +", \ "rows\": "+ Jsonkit.tojson (loginfo.getlist ()) +"} ");}
The corresponding method gets
@Overridepublic page<loginfo> getpagelist (int Page, int rows, String sql,list<object> param) {if (param.size () ==0) {Param.add (1);} page<loginfo> list= LogInfo.me.paginate (page, rows, "Select * ", "from Loginfo where 1=? ") +sql, Param.toarray ()); return list;}
JAVa jfinal + Eazyui =grid Example