views:

503

answers:

3

Anyone know how to set the default sort order for the mvccontrib grid?

+3  A: 

It appears to me that the grid itself doesn't do any sorting. It simply renders the items in the data source in the order that they appear. As such, you'll need to sort the data source before creating the grid or reassign the data source on sorting with the items properly sorted by the column chosen.

Source code available here.

tvanfosson
A: 

Most grid controls require you to supply your own ordering code and this one is no different. This allows you to provide the ordering that you feel is appropriate - for example ordering strings with numbers using the natural order instead of comparison order.

MikeJ
+1  A: 

You can use a labda expresion .OrderBY(x => x.Col)

Why not let your users pick the sort order?

search for * File: jquery.dataTables.min.js * Version: 1.4.3 * Author: Allan Jardine (www.sprymedia.co.uk)

He's done some killer examples, it works great with mvcContrib

James Fleming
sprymedia.co.uk gots lots of interesting stuff, thanks for the tip.
jesperlind