Requirements: Complete the Paginaton paging function in Easyui-datagrid.
Configuration of the 1.easyui-datagrig
<table id= "DG" Rownumbers=true fitcolumns= "true" singleselect= "true" data-options= "Pagination:true,fit:true,toolbar: ' #tt '" ><thead><tr><th field= "bNo" align= "center "Width=" 120px "> Teller No. </th><th field=" btype "align=" center "width=" 150px "> Teller type </th><th field=" Jgno "align=" center "width=" 120px "> Organization number </th><th field=" Pzcount "align=" center "width=" 120px "> Voucher number </ th><th field= "Zjcount" align= "center" width= "120px" > Number of main pieces </th><th field= "Fjcount" align= "center" Width= "120px" > Number of Attachments </th><th field= "Sbpass" align= "center" width= "150px" > Identification voucher </th><th field= " Sbsuccess "align=" center "width=" 150px "> Identify success </th><th field=" Sbroute "align=" center "width=" 120px "> Recognition rate </th><th field= "ywdate" align= "center" width= "170px" > Business date </th></tr></thead></ Table>
The pagination= "true" data table automatically places the page bar below the table, and toolbar= "#tt" indicates that the toolbar is added above the data table, and that the style is determined by the module id= "#tt". Look at the other configurations of the JS file for the DataGrid:
$ (' #dg '). DataGrid ({url: ' user/querylist.action ', pagelist: [5,10,20,50,100], pagesize:5});
The URL refreshes the DataGrid's automatic request for the page, and each request passes two parameters to the background: 1) page, current page, 2) rows, showing several data per page. So in the background need to collect these two important information.
Action Configuration for 2.STRUTS2
Public String querylist () {list<user> List = userservice.querylist (page,rows);p ag1 = new Pagination<user> () ;p ag1.settotal (Userservice.getcount ());p ag1.setrows (list); return SUCCESS;}
<package name= "Work" namespace= "/user" extends= "Json-default,struts-default" ><action name= "QueryList" class= "Useraction" method= "querylist" ><result type= "JSON" ><param name= "root" >pag1</param> </result></action>
</package>
PAG1 for DTO data transfer objects with total and rows two properties (JSON format required by the DataGrid)
3.hibernate Tier Service Paging method
Public list<user> querylist (int page, int pageSize) {//TODO auto-generated method stubstring hql = ' from User '; Query query = userdao.getsession (). CreateQuery (HQL); int beginnum = (page-1) *pagesize;int endnum = beginnum+pagesize> GetCount () GetCount ()-beginnum:p agesize; query.setmaxresults (endnum); Query.setfirstresult (beginnum); return Query.list ();}
Pagination display based on SSH framework, Oracle database, Easyui