标签:
页面初始化时只有一页数据,或没数据时,出现分页控件初始化失败以及后续Ajax分页功能失效的问题,
<div class="pagin"> <div class="message"> @{int totalItemCount = Model == null ? 20 : Model.TotalItemCount;} @{int currentPageIndex = Model == null ? 2 : Model.CurrentPageIndex;} 共 <i class="blue">@totalItemCount </i>条记录,当前显示第 <i class="blue">@currentPageIndex </i>页 </div> <div class="paginList" style="margin-top:-20px; font-size:smaller !important;"> @Ajax.Pager(Model, new PagerOptions{PageIndexParameterName = "id",ContainerTagName = "ul",PrevPageText = "上页",NextPageText = "下页",FirstPageText = "首页",LastPageText = "尾页",CssClass = "pagination",PagerItemsSeperator = "",CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a href=\"#\">{0}</a></li>",PagerItemWrapperFormatString = "<li>{0}</li>",NumericPagerItemCount = 5,AlwaysShowFirstLastPageNumber = true },
new MvcAjaxOptions{UpdateTargetId = "container",HttpMethod = "Post",DataFormId = "searchForm" }, new { style = "float:right" }) </div> </div>
解决方案:
分页插件设置属性:AutoHide=false
<div class="pagin"> <div class="message"> @{int totalItemCount = Model == null ? 20 : Model.TotalItemCount;} @{int currentPageIndex = Model == null ? 2 : Model.CurrentPageIndex;} 共 <i class="blue">@totalItemCount </i>条记录,当前显示第 <i class="blue">@currentPageIndex </i>页 </div> <div class="paginList" style="margin-top:-20px; font-size:smaller !important;"> @Ajax.Pager(Model, new PagerOptions{PageIndexParameterName = "id",ContainerTagName = "ul",PrevPageText = "上页",NextPageText = "下页",FirstPageText = "首页",LastPageText = "尾页",CssClass = "pagination",PagerItemsSeperator = "",CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a href=\"#\">{0}</a></li>",PagerItemWrapperFormatString = "<li>{0}</li>",NumericPagerItemCount = 5,AlwaysShowFirstLastPageNumber = true,AutoHide=false}, new MvcAjaxOptions{UpdateTargetId = "container",HttpMethod = "Post",DataFormId = "searchForm" }, new { style = "float:right" }) </div> </div>
注:MvcPager3.0版本已解决:
从MvcPager 2.0升级到3.0时,需注意以下事项:
标签:
原文地址:http://www.cnblogs.com/xiaoerlang90/p/5206608.html