jquery.pagination.js分页插件的运用
2013-03-14 09:36
776 查看
插件官方地址:http://plugins.jquery.com/project/pagination
分页插件参数说明:
demo
html代码
代码
后台处理代码GetData.ashx
//具体的页面数
int pageIndex;
int.TryParse(context.Request["pageIndex"], out pageIndex);
//排序的依据
string orderType = "ProductID";
int sortType = 1;
if (!string.IsNullOrEmpty(context.Request["sortType"]))
{
string[] strArr = context.Request["sortType"].Split('_');
if (strArr[1] == "0")
{
orderType = strArr[0];
sortType = 0;
}
else
{
orderType = strArr[0];
sortType = 1;
}
}
if (pageIndex == 0)
{
pageIndex = 1;
}
//调用分页的存储过程了
……
分页插件参数说明:
参数名 | 描述 | 参数值 |
---|---|---|
maxentries | 总条目数 | 必选参数,整数 |
items_per_page | 每页显示的条目数 | 可选参数,默认是10 |
num_display_entries | 连续分页主体部分显示的分页条目数 | 可选参数,默认是10 |
current_page | 当前选中的页面 | 可选参数,默认是0,表示第1页 |
num_edge_entries | 两侧显示的首尾分页的条目数 | 可选参数,默认是0 |
link_to | 分页的链接 | 字符串,可选参数,默认是"#" |
prev_text | “前一页”分页按钮上显示的文字 | 字符串参数,可选,默认是"Prev" |
next_text | “下一页”分页按钮上显示的文字 | 字符串参数,可选,默认是"Next" |
ellipse_text | 省略的页数用什么文字表示 | 可选字符串参数,默认是"…" |
prev_show_always | 是否显示“前一页”分页按钮 | 布尔型,可选参数,默认为true,即显示“前一页”按钮 |
next_show_always | 是否显示“下一页”分页按钮 | 布尔型,可选参数,默认为true,即显示“下一页”按钮 |
callback | 回调函数 | 当点击链接的时候此函数被调用,此函数接受两个参数,新一页的id和pagination容器(一个DOM元素)。如果回调函数返回false,则pagination事件停止执行 |
html代码
代码
<script src="common/jquery.js" type="text/javascript"></script> <script src="common/jquery.pagination.js" type="text/javascript"></script> <link href="common/tablesorter.css" rel="stylesheet" type="text/css" /> <link href="common/pagination.css" rel="stylesheet" type="text/css" /> <script language="javascript" type="text/javascript"> var orderby = ""; //进行排序的依据 $(document).ready(function() { InitData(0); //初始化数据 }); //这个事件是在翻页时候用的 function pageselectCallback(page_id, jq) { InitData(page_id); } function InitData(pageIndex) { var tbody = ""; //声明表格中body部分 $.ajax({ //这里使用到Jquery的ajax方法 type: "POST", dataType: "json", url: 'GetData.ashx', //请求的处理数据 data: "pageIndex=" + (pageIndex + 1) + "&sortType=" + orderby, //传入的参数,第一个参数就是分页的页数,第二个参数为排序的依据 //下面的操作就是成功返回数据以后,进行数据的绑定 success: function(data) { $("#linkTable tr:gt(0)").remove(); var myData = data.Products; $.each(myData, function(i, n) { var trs = ""; trs += "<tr><td align='center'>" + n.ProductName + "</td><td>" + n.QuantityPerUnit + "</td></tr>"; tbody += trs; }); $("#linkTable").append(tbody); } }); //加入分页的绑定 $("#Pagination").pagination(<%=pageCount %>, { callback: pageselectCallback, prev_text: '< 上一页', next_text: '下一页 >', items_per_page: 20, num_display_entries: 6, current_page: pageIndex, num_edge_entries: 2 }); } </script> <div> <table id="linkTable" cellpadding="6" cellspacing="1" align="left" class="tablesorter" style="width:400px;margin:0 0 20px 5px;"> <thead> <tr class="tableHeader" align="center"> <th style="width:200px; text-align:center;" > 产品名称 </th> <th style="width:200px; text-align:center"> 产品单价 </th> </tr> </thead> </table> </div> <div id="Pagination" class="digg"></div>
后台处理代码GetData.ashx
//具体的页面数
int pageIndex;
int.TryParse(context.Request["pageIndex"], out pageIndex);
//排序的依据
string orderType = "ProductID";
int sortType = 1;
if (!string.IsNullOrEmpty(context.Request["sortType"]))
{
string[] strArr = context.Request["sortType"].Split('_');
if (strArr[1] == "0")
{
orderType = strArr[0];
sortType = 0;
}
else
{
orderType = strArr[0];
sortType = 1;
}
}
if (pageIndex == 0)
{
pageIndex = 1;
}
//调用分页的存储过程了
……
相关文章推荐
- jquery.pagination.js分页插件的运用
- jquery.pagination.js分页插件的运用
- jquery.pagination.js分页插件的运用
- jquery.pagination.js分页插件的运用
- jquery.pagination.js分页插件的运用
- [转]jquery.pagination.js分页插件的运用
- jquery分页插件jquery.pagination.js使用方法解析
- asp.net jquery无刷新分页插件(jquery.pagination.js)
- 【js】jQuery Pagination分页插件( 添加支持 首页,末页)
- 一款简单易用的分页插件jquery-sdpagination.js(17-02-09更新涉及Sass/Scss、皮肤)
- jQuery分页插件jquery.pagination.js使用
- jquery分页插件pagination 的运用
- 实用jQuery分页特效插件jquery.pagination.js
- 采用Jquery无刷新分页插件jquery.pagination.js 实现无刷新分页效果
- jquery.pagination.js分页插件的使用
- 采用Jquery无刷新分页插件jquery.pagination.js 实现无刷新分页效果
- 分页插件jquery.pagination.js
- jquery分页插件jquery.pagination.js实现无刷新分页
- 分页插件 jquery.pagination.js