Use StaticPagedList with PagedListRenderOptions

你说的曾经没有我的故事 提交于 2019-12-23 22:59:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!