[英]MvcContrib.UI.Grid pagination problem
I have an object which contains quite a few other objects in an IList called possible values. 我有一个对象,该对象在IList中包含很多其他对象,称为可能值。 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. 我以前已经成功使用了mvccontrib网格和分页功能,但想将网格添加到对象的页面中-希望您知道我的意思。 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"]. PossibleValues绝对包含数据,但不包含ViewData [“ PossibleValues”]。 Is this because AsPagination relies on lazy loading or something? 这是因为AsPagination依赖于延迟加载等吗? 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>))%>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.