MVCContrib 网格 - 对自定义列进行排序
刚刚开始学习使用网格,所以请原谅我提出一个可能很琐碎的问题。
如何按使用另一个表属性的列进行排序? 对于前。column.For(cust => cust.LinkedTable.someProperty).Sortable(true);
定义导致“在 MyProject.Models 类型上找不到名为“someProperty”的属性。 Node”错误(明显 - 该属性实际上是 MyProject.Models.Node.LinkedTable.someProperty)
我的想法之一是创建一个帮助器:
column.For(cust => Helpers.ViewHelper.GetSomeProperty(cust)).Sortable(true);
这不会产生错误,但列无论如何都不会被排序。
换句话说,有没有办法将字符串值传递给列并使其可排序?
也许应该重写我的排序函数(现在只是一个 OrderBy(...) ),但我真的不知道如何开始:) 任何帮助将不胜感激!
Just started learning to use the grid so please excuse me for the possibly trivial question.
How can I sort by a column that uses another table property?
For ex.column.For(cust => cust.LinkedTable.someProperty).Sortable(true);
definition results in a "Could not find a property called 'someProperty' on type MyProject.Models.Node" error (obvious - the property is actually MyProject.Models.Node.LinkedTable.someProperty)
One of my ideas was to create a helper:
column.For(cust => Helpers.ViewHelper.GetSomeProperty(cust)).Sortable(true);
This doesn't produce the error, but a column isn't getting sorted anyways.
In another words, is there any way to pass a string value to a column and make it sortable?
Should probably rewrite my sort function (just a OrderBy(...) now), but I don't really know how to start:) Any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以这样做:
其中
somePropertyID
是表cust
的属性。You can do it like this:
where
somePropertyID
is a attribute of tablecust
.我想向您推荐 JQuery grid
看看,它非常有用
I would like to recommend you the JQuery grid
Check it out, it's very useful