pklosinski
pklosinski

Reputation: 229

MVCContrib grid - sorting a custom column

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!

Upvotes: 3

Views: 1202

Answers (2)

robon
robon

Reputation: 31

You can do it like this:

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

where somePropertyID is a attribute of table cust.

Upvotes: 3

muek
muek

Reputation: 1080

I would like to recommend you the JQuery grid

Check it out, it's very useful

Upvotes: 0

Related Questions