我正在使用WebGrid来显示我的信息。我的一个页面的问题是分页和排序不起作用。它适用于所有其他页面,但在一个页面上没有任何事情发生。
Here is the code for the controller
public IndiceController(IMapperFacade mapperFacade, IDonneeReferenceService<Indice> indiceService, ILogWriters logWriters)
{
this.indiceReference = indiceService;
MapperFacade = mapperFacade;
}
public ViewResult Index(bool afficherSupprime = false)
{
var models = this.ApplyInitialSort(indiceReference.GetAll(!afficherSupprime));
var viewModels = MapperFacade.GetViewModelList<Indice, IndiceViewModel>(models);
var viewModel = new ListeViewModel<IndiceViewModel>(afficherSupprime, viewModels);
this.ViewBag.RowsPerPage = 3;
return View("Index", viewModel);
}
Here is the view
@using CDP.CMG.WebUI.ViewModels.Shared
@model ListeViewModel<IndiceViewModel>
@{
Layout = "~/Views/Shared/_ListeLayout.cshtml";
ViewBag.Title = Layouts.Indice_Index_Title;
ViewBag.HeaderTitle = Layouts.Indice_Index_Title;
var grid = new WebGrid(rowsPerPage: ViewBag.RowsPerPage);
grid.Bind(Model.ViewModels, autoSortAndPage: true, rowCount: Model.ViewModels.Count());
}
@grid.GetHtml("table table-striped table-hover",mode: WebGridPagerModes.All)
Any ideas where i'am missing something ?
Thank for the help.
答案 0 :(得分:0)
我对分页和排序的问题来自WebGrid周围使用的分部类。 由于某些原因,我无法解释分页和排序不起作用。通过删除部分类,一切都恢复正常。
所以我的解决方案是删除代码中用于显示WebGrid的部分类