This question is locked. New answers and comments are not allowed.
Hi,
I'm using the grid with AJAX and sorting enabled. However I cannot find a way to specify the initial sort. When my user arrives on the page I want the grid to be sorted by the name column. Currently they have to click on the Name column heading to sort by name. I've added a default sort in the server code (i.e. if no sort is specified it sorts by name) but that's not great usability wise; both no sort and sort by name are then the same. Ideally you would be able to specify this when you define the columns, e.g.:
(Not suggesting you add this method of course, merely using it as an example of how you might want to add extra builder methods)
Thanks,
Kev
I'm using the grid with AJAX and sorting enabled. However I cannot find a way to specify the initial sort. When my user arrives on the page I want the grid to be sorted by the name column. Currently they have to click on the Name column heading to sort by name. I've added a default sort in the server code (i.e. if no sort is specified it sorts by name) but that's not great usability wise; both no sort and sort by name are then the same. Ideally you would be able to specify this when you define the columns, e.g.:
| <% = Html.Telerik().Grid<OfficialSummary>() |
| .Name("Grid") |
| .Columns(columns => |
| { |
| columns.Add(o => o.Name).Sorted(ListSortDirection.Ascending); |
Although not sure how easy that will be as I don't believe the GridColumn class has a reference back to the parent Grid?
On a related note it would also be nice to be able to specify that a grid should always have a sort, i.e. if you're sorted by name descending and click on the column header it changes to sorted by name ascending rather than no sort.
And on a further related note the Component property of ViewComponentBuilderBase is protected internal. Perhaps make this public? That way people could write extension methods to do extra stuff with the components, e.g. I could add something like:
| public static GridBuilder<T> Sort<T>(this GridBuilder<T> gridBuilder, string member, ListSortDirection sortDirection) |
| where T : class |
| { |
| gridBuilder.Component.DataProcessor.SortDescriptors.Add(new SortDescriptor { Member = member, SortDirection = sortDirection }); |
| return gridBuilder; |
| } |
(Not suggesting you add this method of course, merely using it as an example of how you might want to add extra builder methods)
Thanks,
Kev