在使用Ajax.Pager進(jìn)行分頁(yè)的時(shí)候需要注意一下幾個(gè)方面:
1、一定要引入jquery.unobtrusive-ajax.min.js這個(gè)js;
2、一定要在頁(yè)面中使用注冊(cè)分頁(yè)器,注冊(cè)方法:@{Html.RegisterMvcPagerScriptResource();};
具體的使用方法示例:
<div class="row" style="position: relative; left: 30%"> <div class="col-md-8" style="width: auto"> @{ PagerConfig pagerConfig = new PagerConfig("pageIndex", "pageIndexBox", "goToBtn"); PagerOptions options = pagerConfig.GetPagerOption(); } @Ajax.Pager(Model, options).AjaxOptions(a => a.SetUpdateTargetId("articles").SetHttpMethod("Post").SetDataFormId("searchView")) </div> <div class="col-md-4"> <div class="input-group" style="width: 120px; margin: 20px 0"> <input type="text" id="pageIndexBox" class="form-control" /> <span class="input-group-btn"><button class="btn btn-primary" id="goToBtn">跳轉(zhuǎn)</button></span> </div> </div> </div>
其中Model是IpagedList對(duì)象,獲取PagerOptions的方法如下:
/// <summary> /// 翻頁(yè)配置項(xiàng) /// </summary> /// <returns></returns> public PagerOptions GetPagerOption() { PagerOptions options = new PagerOptions { AutoHide = false, FirstPageText = "首頁(yè)", LastPageText = "尾頁(yè)", NextPageText = "下一頁(yè)", PrevPageText = "上一頁(yè)", PageIndexParameterName = this._pageIndexParaName, ContainerTagName = "ul", CssClass = "pagination", CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>", DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>", PagerItemTemplate = "<li>{0}</li>", PageIndexBoxId = this._pageIndexBoxId, GoToButtonId = this._goToButtonId, NumericPagerItemCount = 5 }; return options; }
目前所知,該控件不支持顯示記錄總數(shù)及總頁(yè)數(shù)。
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com