基於bootstrap的分頁

來源:互聯網
上載者:User

標籤:des   cPage   style   blog   http   color   java   os   

由於之前寫了一個局部重新整理的分頁,為了自己以後工作方便所以再上傳一個通用的分頁,基於bootstrap的分頁,引用和上次寫的局部重新整理一樣,在這裡就不寫了

js代碼 在頁面載入的時候執行

   var options = {                bootstrapMajorVersion: 3,//版本                currentPage: @Convert.ToInt64(Model.PageNumber) ,//當前頁數                numberOfPages: 10,//設定顯示的頁碼數                totalPages: @Convert.ToInt64(Model.PageCount) ,//總頁數                itemTexts: function (type, page, current) {                    switch (type) {                        case "first":                            return "首頁";                        case "prev":                            return "上一頁";                        case "next":                            return "下一頁";                        case "last":                            return "末頁";                        case "page":                            return page;                    }                },                pageUrl: function (type, page, current) {                    return "/Comment/CarReply?pageIndex=" + page;                }            };            element.bootstrapPaginator(options);

  

html

<div><ul id="page"></ul></div>

Controller代碼(需要返回分頁類型)

 

[AuthorizationCodeAttribute]       [Description("評論資訊")]       [HttpPost]       public ActionResult Comment(int id,int? page)       {           #region 評論列表                    var dal = new CarCommentOperator();           int pageIndex = page ?? 1;//當前頁           if (!string.IsNullOrEmpty(Request.QueryString["pageindex"]))           {               if (!int.TryParse(Request.QueryString["pageindex"], out pageIndex))               {                   pageIndex = 1;               }           }           const int pageSize = 2;           long totalCount;           long totalPageCount;                    IEnumerable<CarComment> list = dal.GetList(pageIndex, pageSize, out totalPageCount, out totalCount, "CarId=" + id);           var commentIPagedList = new StaticPagedList<CarComment>(list, pageIndex, pageSize, Convert.ToInt32(totalCount));           #endregion       return View(commentIPagedList);        }

 

  

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.