码迷,mamicode.com
首页 > Web开发 > 详细

jQuery Pagination分页插件的使用

时间:2015-06-08 13:16:56      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

一、引用CSS和JS:

技术分享
<link href="/Content/Plugins/jQuery.Pagination_v2.2/pagination.css" rel="stylesheet"
    type="text/css" />
<script src="/Content/Plugins/jQuery.Pagination_v2.2/jquery.pagination.js" type="text/javascript"></script>
View Code

二、HTML:

技术分享
<div id="Pagination" class="flickr" style="margin-top: 10px; margin-left: 10px;">
</div>
View Code

三、JS:

技术分享
$(function () {
    var total = parseInt("@(ViewBag.total)");
    var page = parseInt("@(ViewBag.page)") - 1;
    var pageSize = parseInt("@(ViewBag.pageSize)");

    $("#Pagination").pagination(total, {
        callback: function (page_id) {
            window.location = "BoardList?page=" + page_id + "&pageSize=" + this.items_per_page;
        }, //PageCallback() 为翻页调用次函数。
        prev_text: " 上一页",
        next_text: "下一页 ",
        items_per_page: 10, //每页的数据个数
        num_display_entries: 1, //两侧首尾分页条目数
        current_page: page,   //当前页码
        num_edge_entries: 11 //连续分页主体部分分页条目数
    });
});
View Code

四、后台代码:

技术分享
public ActionResult BoardList()
{
    PagerModel pager = new PagerModel();
    if (Request["page"] == null)
    {
        pager.page = 1;
        pager.rows = 10;
        pager.sort = "Id";
        pager.order = "desc";
    }
    else
    {
        pager.page = int.Parse(Request["page"]) + 1;
        pager.rows = int.Parse(Request["pageSize"]);
        pager.sort = "Id";
        pager.order = "desc";
    }

    boardManageService.GetList(ref pager);
    List<BoardModel> boardList = pager.result as List<BoardModel>;
    ViewData["BoardModelList"] = boardList;
    ViewBag.page = pager.page;
    ViewBag.total = pager.totalRows;
    ViewBag.pageSize = pager.rows;

    return View();
}
#endregion
View Code

 

jQuery Pagination分页插件的使用

标签:

原文地址:http://www.cnblogs.com/s0611163/p/4560589.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!