MvcContrib.UI.Grid pagination problem

扶醉桌前 提交于 2019-12-12 01:30:36

问题


I have an object which contains quite a few other objects in an IList called possible values. I have successfully used the mvccontrib grid plus paging before but would like to add the grid to the object’s page – hope you know what I mean. So I did something like this in my controller:

[AcceptVerbs(HttpVerbs.Get)]
public ViewResult Bla(string Id, int? page)

ViewData["PossibleValues"] = XYZ.PossibleValues.AsPagination(page ?? 1, 10);

PossibleValues definitely contains data but not ViewData["PossibleValues"]. Is this because AsPagination relies on lazy loading or something? Thanks.

Chris


回答1:


Just figured it out. Use in the controller:

ViewData["PossibleValues"] = XYZ.PossibleValues.ToList().AsQueryable().AsPagination(page ?? 1, 10);

Then in the view:

<%= Html.Grid(ViewData["PossibleValues"] as IEnumerable<FFFF>).Columns(column =>
                           {
                            column.For(gf => gf.Value).Named("Value");
                        }).Empty("Sorry no data.")%>
                       <%= Html.Pager((IPagination)(ViewData["PossibleValues"] as IEnumerable<FFFF>))%>


来源:https://stackoverflow.com/questions/3227707/mvccontrib-ui-grid-pagination-problem

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