问题
Using PagedList of MVC. Not able to get Property:
PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.IfNeeded }
Note that I'm using StaticPagedList not PagedListPager.
My Requirement is : pagedlist-pagination
Not able to find syntax to use StaticPagedList with PagedListRenderOptions
回答1:
Pass the paging meta data as separate property and construct the IPagedList
in the view. Like this:
public class PagedClientViewModel
{
public int? Page { get; set; }
public List<YourModel> ListofModel { get; set; }
public IPagedList PagingMetaData { get; set; }
}
And the metadata
can be generated like this:
pagedYourModel.PagingMetaData = new StaticPagedList<YourModel>(pagedYourModel.Clients,
pageIndex, pageSize, TotalCount).GetMetaData();
Then use the pager in view like this:
@Html.PagedListPager(
new StaticPagedList<YourModel>(Model.ListofModel , Model.PagingMetaData),
page => Url.Action("ActionName", new { page }), PagedListRenderOptions.Classic)
来源:https://stackoverflow.com/questions/28083158/use-staticpagedlist-with-pagedlistrenderoptions