Home > Web Front-end > JS Tutorial > body text

A js paging package based on jquery_jquery

WBOY
Release: 2016-05-16 17:59:23
Original
1209 people have browsed it
Copy code The code is as follows:

(function ($) {
var PageFunc = function PageFunc( ) { }
$.PageFunc = function (Total, PageSize, curPageNum, FunUrl) {
if (PageSize == "" || PageSize == null || PageSize == undefined) {
PageSize = 10;
}
if (curPageNum == "" || curPageNum == null || curPageNum == undefined) {
curPageNum = 1;
}
//Calculate the total number of pages
Total = parseInt(Total); //Total number of records
PageSize = parseInt(PageSize); //Number displayed per page
curPageNum = parseInt(curPageNum); //Current page
// Total number of pages
var AllPage = Math.floor(Total / PageSize);
if (Total % PageSize != 0) {
AllPage ;
}

var navHtml = " ";

if (curPageNum <= 0)
curPageNum = 1;
if (AllPage > 1) {
if (curPageNum != 1) {
// Handle homepage connection
navHtml = "|< ";
}
if (curPageNum > 1) {
//Handle the connection to the previous page
navHtml = "<< ";
}
else {
navHtml = "< ;< ";
}

var currint = 5;
for (var i = 0; i <= 10; i ) {
//Total Display up to 10 page numbers, 5 in front and 5 in back
if ((curPageNum i - currint) >= 1 && (curPageNum i - currint) <= AllPage)
if (currint == i) {
//Current page processing
navHtml = "[" curPageNum "] ";
}
else {
/ /General page processing
var n = curPageNum i - currint;
navHtml = "" n " ";
}
}
if (curPageNum < AllPage) {
//Process the link to the next page
navHtml = ">> ";
}
else {
navHtml = ">> ";
}

if (curPageNum != AllPage) {
navHtml = " >|  ";
}

}

navHtml = "[" curPageNum "/" AllPage "] ";

return navHtml;

};

})(jQuery);

The following is the calling method:
Copy code The code is as follows:

function QueryList(curpage) {
if (curpage == "" || curpage == null || curpage == undefined) {
curpage = 1;
}
var pagesize = 10;

var Countys = $("#Countys").val(); //县
var enddate = $("#enddate").val(); //结束时间
var begindate = $("#begindate").val(); //开始时间
$.ajax({
url: "",
type: "POST",
data: { "Countys": Countys, "enddate": enddate, "begindate": begindate, "curpage": curpage, "pagesize": pagesize },
dataType: "json",
error: function (xhr, status, errMsg) { window.location.href = "/CommonError/index/" errMsg.code "?txt=" errMsg.msg; },
success: function (mydata) {
var str = "";
$.each(mydata.Tdata, function (i, item) {

str = ""
str = "" $.FormatDateTime(item.ControlBeginTime, false) "";
str = "" $.FormatDateTime(item.ControlEndTime, false) "";
str = "" item.Name "";
str = "" item.PlateNumber "";
str = "" item.ControlDept "";
if (item.IsAll == "0") {
str = "全县布控";
}
else {
str = "按卡口点布控";
}
str = "" item.IsAll == "0" ? "全县布控" : "按卡口点布控" "";
str = "修改";
str = "删除";
str = "详细";
str "";
});

$("#srh_rslt tbody").html(str);

$(".pagination").html($.PageFunc(mydata.total, pagesize, curpage, "QueryList"));
}
});
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template