/**
* Author: DL
* Time: 2014-3-19
* The Pagingtool module provides the most basic, Web-based toolbars. and page data back to the Phone Extensibility Page toolbar introduction, and pages rendered data
* Idea: Must quote json.js
* @module Pagingtool
*/
var pagingtool = {}
Pagingtool.init = {}//Initialize the number of references
Pagingtool.funpagecallback = function (data) {
var pparams = data.pparams;//Query the number of references
var PageCount = data.pagecount;//Display entries per page
var totalpages = data.totalpages;//Total Pages
var pageIndex = data.pParams.intNowPage; Current page
var pagetargetid = Data.pagetargetid;
var totalcount = Data.totalcount;
var pagehtml = "";
if (TotalPages > 1) {
var beginpage = 1, endpage = 1;
Beginpage = parseint ((pageIndex-1)/pagecount) * PageCount + 1;
EndPage = parseint ((pageIndex-1)/pagecount) * PageCount + PageCount;
EndPage = endpage > totalpages?
Totalpages:endpage;
if (PageIndex > 1)//prev
{
pparams["Intnowpage"] = 1;
pagehtml + = ' <a href=\ "javascript:;\" Onclick=\ ' pagingtool.paging (' + json.stringify (pparams) + ') \ ' ><< </a> ';
pparams["intnowpage"] = pageIndex-1;
pagehtml + = ' <a href=\ "javascript:;\" Onclick=\ ' pagingtool.paging (' + json.stringify (pparams) + ') \ ' ><</a > '
}
else {
pagehtml + = ' <a href=\ ' javascript:;\ ' ><<</a> '
pagehtml + = ' <a href=\ ' javascript:;\ ' ><</a> '
}
if (BeginPage-1 > 1) {
pparams["intnowpage"] = beginPage-1;
pagehtml + = ' <a href=\ "javascript:;\" Onclick=\ ' pagingtool.paging (' + json.stringify (pparams) + ') \ ' >...</a > '
}
Middle Page
for (var i = beginpage; I <= endpage; i++) {
if (PageIndex = = i) {
pagehtml + = ' <a href=\ "javascript:;\" class=\ "current\" > ' + i + ' </a> ';
}
else {
pparams["intnowpage"] = i;
pagehtml + = ' <a href=\ "javascript:;\" Onclick=\ ' pagingtool.paging (' + json.stringify (pparams) + ') \ ' > ' + i + ' </a > '
}
}
if (Totalpages-endpage > 1) {
pparams["intnowpage"] = endpage + 1;
pagehtml + = ' <a href=\ "javascript:;\" Onclick=\ ' pagingtool.paging (' + json.stringify (pparams) + ') \ ' >...</a > '
}
if (PageIndex < totalpages) {
pparams["intnowpage"] = PageIndex + 1;
pagehtml + = ' <a href=\ "javascript:;\" Onclick=\ ' pagingtool.paging (' + json.stringify (pparams) + ') \ ' >></a > '
pparams["intnowpage"] = totalpages;
pagehtml + = ' <a href=\ "javascript:;\" Onclick=\ ' pagingtool.paging (' + json.stringify (pparams) + ') \ ' >>> </a> ';
}
else {
pagehtml + = ' <a href=\ ' javascript:;\ ' >></a> '
pagehtml + = ' <a href=\ ' javascript:;\ ' >>></a> '
}
$ ("#" + Pagetargetid). HTML (pagehtml);
} else {
$ ("#" + Pagetargetid). HTML ("");
}
}
/**
* Returns the element at the specified position in the current collection
* @method pagingtool.paging Page Operation method
* @param {pparams} query condition {"Intustate": 0, "intnowpage": 1, "Inttype": 1, "Intpagesize": 3}
* @return {html} returns HTML Loadingicon.gif
*/
pagingtool.paging = function (pparams) {
var fundcallback = PagingTool.Init.DataCallBack;
var funpcallback = PagingTool.Init.PageCallBack
var appendid = PagingTool.Init.AppendId;
var targetid = PagingTool.Init.PageTargetId;
var pageSize = PagingTool.Init.PageSize;
var pagecount = PagingTool.Init.PageCount;
$.ajax ({
URL:PAGINGTOOL.INIT.URL,
Data:pparams,
Type:PagingTool.Init.Type,
DataType: "JSON",
Beforesend:function () {
var iselement = document.getElementById (appendid). NodeName;
var html = "";
if (iselement = = "DIV") {
html = ' <div id= ' sload "style=" text-align:center; margin-top:30px; " ><image src= "/content/image/base/loadingicon.gif"/></div> ';
}
else {
html = ' <tr id= ' sload "><td colspan=" style= "Text-align:center;" ><image src= "/content/image/base/loadingicon.gif"/></td></tr> ';
}
$ ("#" + appendid). HTML (HTML);
},
Complete:function () {
$ ("#sload"). Remove ();
},
Error:function () {
$ ("#sload"). Remove ();
},
Success:function (data) {
var totalcount = data. TotalCount;
var jieancount = Data.jieancount;
if (TotalCount > 0) {
var totalpages = parseint ((totalCount-1)/pageSize + 1);
var calldbackparams = {"Appendid": Appendid, "jsondata": Data, "TotalCount": TotalCount, "Jieancount": Jieancount};
var callpbackparams = {"Pagetargetid": Targetid, "pageSize": PageSize, "totalpages": TotalPages, "PageCount": PageCount, "TotalCount": TotalCount, "Pparams": Pparams};
Fundcallback (calldbackparams);//Return to function
Funpcallback (callpbackparams);//Paging Control callback function
}
else {
var desc = returnnull (Appendid, 20, "", "");//Hint No data
$ ("#" + Appendid + ""). HTML (DESC);
$ ("#" + Targetid + ""). html ("");
No data
}
}
});
}
/* Method Description Use the Description method Pagetargetid "Page bar rendering location ID" Appendid "Data rendering ID" datacallback "Data callback Function" Pagecallback "page rendering callback function"
Pagingtool.init = {"Url": "/lshsystem/user/ajaxindex", "Type": "POST", "PageCount": 3, "PageSize": 3, "Pagetargetid": "Pa Geid "," Appendid ":" Appendid "," Datacallback ": Fundatacallback," Pagecallback ": Pagingtool.funpagecallback};
Pagingtool.paging ({"Intustate": 0, "intnowpage": 1, "Inttype": 1, "Intpagesize": 3});
Data callback function page operation logic
fundatacallback= function (data) {
var appendid = Data.appendid;
var jsondata = Data.jsonData.PageData;
var htmldata = "";
for (var i = 0; i < jsondata.length; i++) {//Convenience data
HTMLData + = "<tr id=\" Temp "+ i +" \ ">" +
"<td class=\" Thcenter\ ">" +
"<input type=\" checkbox\ "value=\" "+ jsondata[i". Uaccount + "\" name=\ "ckuaccount\"/></td> "+
"<td id=\" uaccount\ ">" + jsondata[i ". Uaccount + "</td>" +
"<td id=\" sfname\ ">" + jsondata[i ". Sfname + "</td> </tr>"
}
$ ("#" + Appendid + ""). html (htmldata);
}
*/
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
JAVASCRPT Page Tools