1
服务器端分页我正在使用PageList。我看到:https://www.youtube.com/watch?v=5omEuuIIFcgMVC实体框架服务器端分页PageList
我正在使用ViewModel。我遵循“丹尼斯R”给出的步骤。
Using a PagedList with a ViewModel ASP.Net MVC
但我有不同的看法模式:
我的实体类
public class Summary
{
}
视图模型是:
public class SummaryViewModel
{
...
....
}
public class DashboardViewModel
{
public List<SummaryViewModel> SummaryRestricted { get; set; }
public List<SummaryViewModel> SummaryUnrestricted { get; set; }
}
我的控制器类:
public ActionResult Display(int page = 1, int pagesize = 4)
{
var entitySummaries = _dbContext.Summaries.ToList();
var vm = MapEntityToViewModel(entitySummaries);
//return View(vm);
//return View(vm.FundsUnrestricted.ToPagedList(page, pagesize)); ????
}
DashboardViewModel MapEntityToViewModel(List<Summary> funds)
{
DashboardViewModel dashboardViewModel = new DashboardViewModel();
List<Summary> unRestricted = funds.Where(x => xxx).ToList() ;
List<Summary> restricted = funds.Where(x => xx).ToList();
dashboardViewModel.SummaryUnrestricted = unRestricted.Select(x => new SummaryViewModel(x)).ToList();
dashboardViewModel.SummaryRestricted = restricted.Select(x => new SummaryViewModel(x)).ToList();
return dashboardViewModel;
}
我的看法是:
@model PagedList.IPagedList<ViewModels.DashboardViewModel>
@using PagedList.Mvc;
@using PagedList;
<table id="Restricted" class="table table-bordered">
@foreach (ViewModels.SummaryViewModel item in Model.SummaryRestricted)
{
<tr> <tr>
}
</table>
<table id="UnRestricted" class="table table-bordered">
@foreach (ViewModels.SummaryViewModel item in Model.SummaryUnrestricted)
{
<tr> <tr>
}
</table>
我的观点具有同时显示的限制摘要和同一页面上不受限制的总结表。任何人都可以帮助我如何应用分页使用pageList的两个表?