Kkpager improvements, AJAX data changes but the page number is the same problem
Kkpager is a simple pagination display plugin that needs to rely on jquery.
: Http://www.oschina.net/action/project/go?id=29450&p=download
Official Document Address: Https://github.com/pgkk/kkpager
Online Testing Links:
Blue Skin: http://pgkk.github.io/kkpager/example/pager_test.html
Orange skin: http://pgkk.github.io/kkpager/example/pager_test_orange_color.html
Click mode: http://pgkk.github.io/kkpager/example/pager_test_clickmode.html
Problems that exist:
In the Ajax refresh dynamic into the page number, regardless of changing the page number, is to display the first page number
Solution.
Modify JS File
Call
This method is online approach, may have friends the second step did not find, I write my version
kkpager.generpagehtml ({pno:pageno,//Total Page NumberTotal:totalpage,//total number of data barstotalrecords:totalrecords, Mode:' Click ',//The default value is link, optional link or clickClick:function(n) { This. Selectpage (n); Loadworkitem (n); return false; }, Gethref:function(n) {return‘#‘; } },true);
In this code, generpagehtml is finally added true in order to reload the config configuration
The above method can modify the page number, but when you click on the page number, the page will change
The following modifications can be made:
The use of Kkpager.
But two problems were found when calling Dynamic Data
1.Ajax data Changes But the page number is the same problem, the method from the online
2. regenerate data and pagination by query criteria, Totalpage and Totalrecord after paging events, and data that is not conditionally queried.
The main reason is because the client will not help you keep the total number of pages and the total number of bars,
So when you re-generate the data by query criteria, use the hidden button to bind your total pages and the total number of bars
The following is the AJAX call background data, the total number of pages returned and total, are stored in the hidden.
$.ajax ({type: "Get", DataType: "JSON", URL:URLSTR2, success:totalonsuccess});//Based on The total loaded data and paging function totalonsuccess (data) {var Resinfoarray = eval (data) returned; Totalrecords = resinfoarray[0]. Total; Totalpage = Math.ceil (totalrecords/pagesize); Rounding up $ ("#totalpages"). Val (totalpage); The total number of pages that the binding obtains is $ ("#totalRecords"). Val (totalrecords);//bind gets the total bar count if (!pageno) {pageno = 1; } if (Totalrecords > 0) {fkeeppage (PageNo, Totalpage, totalrecords); Call a paging plug-in} else {$ ("#kkpager"). HTML ("<div style= ' Text-align:center ' > No qualifying Data </div>")} qu Eryinfotable (tablename, PageSize, PageNo, where); Load Tabular Data}
/*pageno: Current page totalpage: Total pages totalrecords: Total number of bars */function fkeeppage (PageNo, Totalpage, totalrecords) {//RAW ingredients page//have Some parameters are optional, such as Lang, if there is no default value kkpager.generpagehtml ({Pno:pageno,//Total page number Total:totalpage,//Total data bar Number totalrecords:totalrecords, mode: ' click ',//The default value is link, optional link or click Click:function (n) { Do something//This.selectpage (n); Default because it does not meet my requirements change to the following
This.selectpage (N, $ ("#totalpages"). Val (), $ ("#totalRecords"). Val ());
Queryinfotable (tablename, PageSize, N, where); Load table data return false; }/*, Lang: {firstpagetext: ' Home ', Firstpagetiptext : ' Home ', Lastpagetext: ' Last ', Lastpagetiptext: ' Last ', Prepagetext : ' Previous ', Prepagetiptext: ' prev ', NextPageText: ' next page ', Nextpagetiptext: ' next page ', Totalpagebeforetext: ' Total ', Totalpageaftertext: ' Page ', Currpagebeforetext: ' Current section ', Currpageaftertext: ' Page ', totalinfosplitstr : '/', Totalrecordsbeforetext: ' Total ', Totalrecordsaftertext: ' Data ', GOPAGEB Eforetext: ' go ', gopagebuttonoktext: ' OK ', Gopageaftertext: ' Page ', Buttontipbeforetext: ' The first ', Buttontipaftertext: ' page '}*/},true);//plus true default, because the number of pages is not updated, so added}
The following is the modification kkpager.js
The main thing is to put the inside
Do not refresh the page directly by manually calling select a page number Selectpage:function (n) { this.generpagehtml (this._config,true);},
Change into
Do not refresh the page directly by manually calling select a page number Selectpage:function (n, b, c) {this._config[' pno ') = n;this._config[' total ' = b;this._config[' Totalrecords '] = c;this.generpagehtml (this._config,true);},
Reference: http://www.myexception.cn/ajax/1910086.html
Http://www.bubuko.com/infodetail-1906367.html
Kkpager improvements, AJAX data changes but the page number does not change the question