是否可以将MvcContrib网格页面的样式设置为仅显示"1 2 3 4 ...“用于寻呼?
发布于 2011-04-08 17:27:09
据我所知,这个选项是不存在的。我在codeplex上问了同样的问题,但它似乎还没有准备好:
http://mvccontrib.codeplex.com/workitem/5745
发布于 2012-07-06 01:37:05
下面是我对这些特性的实现:
@using MvcContrib.UI.Pager
@model MvcContrib.Pagination.IPagination
@{
string action = ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString();
string controller = ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString();
}
@functions
{
public RouteValueDictionary GetRoute(int page)
{
var routeValues = new RouteValueDictionary();
foreach (var key in Context.Request.QueryString.AllKeys.Where(key => key != null))
{
routeValues[key] = Context.Request.QueryString[key];
}
routeValues["page"] = page;
return routeValues;
}
}
<div class="pagination">
<center>
<span class="paginationRight">
@{
int thisPage = Model.PageNumber;
if (Model.HasPreviousPage)
{
for (int i = (5 < Model.PageNumber ? 5 : Model.PageNumber); i >= 1; i--)
{
int page = thisPage - i;
if (page > 0)
{
<text>
@Html.ActionLink(page.ToString(), action, controller, GetRoute(page), null)
</text>
}
}
}
<text> | @Model.PageNumber | </text>
if (Model.HasNextPage)
{
for (int i = 1; i <= (5 < Model.TotalPages - Model.PageNumber ? 5 : Model.TotalPages - Model.PageNumber); i++)
{
int page = thisPage + i;
if (page > 0)
{
<text>
@Html.ActionLink(page.ToString(), action, controller, GetRoute(page), null)
</text>
}
}
}
}
</span>
</center>
</div>它并不漂亮,但它对我来说工作得很好,而且根据你的需要对它进行修改非常简单。
https://stackoverflow.com/questions/3557107
复制相似问题