开发者

MvcContrib.UI.Grid pagination problem

开发者 https://www.devze.com 2023-01-07 10:38 出处:网络
I have an object which contains quite a few other objects in an IList called possible values. I have successfully used t开发者_如何学Che mvccontrib grid plus paging before but would like to add the gr

I have an object which contains quite a few other objects in an IList called possible values. I have successfully used t开发者_如何学Che 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


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>))%>
0

精彩评论

暂无评论...
验证码 换一张
取 消