我觉得你需要这个
对于分页,您可以使用 MVC4.Paging。
@Html.Raw(Ajax.Pager(
new Options
{
PageSize = Model.PageSize,
TotalItemCount = Model.TotalItemCount,
CurrentPage = Model.PageNumber,
ItemTexts = new ItemTexts() { Next = "Next", Previous = "Previous", Page = "P" },
ItemIcon = new ItemIcon() { First = "icon-backward", Previous = "icon-chevron-left", Next = "icon-chevron-right", Last = "icon-forward" },
TooltipTitles = new TooltipTitles() { Next = "Next page", Previous = "Previous page", Page = "Go to page {0}.", First = "Go To First Page", Last = "Go To Last Page" },
Size = Size.normal,
Alignment = Alignment.centered,
IsShowControls = true,
IsShowFirstLast = true
},
new AjaxOptions
{
UpdateTargetId = "grid-list",
OnBegin = "beginPaging",
OnSuccess = "successPaging",
OnFailure = "failurePaging"
}, new { controller = "Home", action = "Index", employee_name = ViewData["employee_name"] }))
参考: http: //mvcpaging.apphb.com/
我已经实现了它并且它有效!
示例中提到了没有回发的分页。
安装 nuGet 包后,
在将模型传递回 View 或 PartialView 时,您需要使用ToPagedList
myModel = myModel.ToPagedList(currentPageIndex,rowSize);
上面的代码会为你变魔术!
但是,如果您想在 AJAX 调用之后更改您的 URL,那么您需要付出更多的额外努力。
ref :如何在 ajax 请求后更改 URL?