开发者

MVCContrib grid - sorting a custom column

开发者 https://www.devze.com 2023-01-16 05:46 出处:网络
Just sta开发者_JS百科rted learning to use the grid so please excuse me for the possibly trivial question.

Just sta开发者_JS百科rted 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!


You can do it like this:

column.For(cust => cust.LinkedTable.someProperty).SortColumnName(somePropertyID)

where somePropertyID is a attribute of table cust.


I would like to recommend you the JQuery grid

Check it out, it's very useful

0

精彩评论

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