Sorting is controlled by columns.
PropertyColumn, sorting is enabled if you set
Sortable="true". You should do this only if your underlying data source supports sorting by this column's property expression.
TemplateColumn, sorting is enabled if you supply a value for the column's
ColumnBase, sorting is enabled if you set
Sortable="true"or if you override
You can also specify
InitialSortDirection on a column with value
SortDirection.Descending to indicate the grid's initial sort order.
If you are using an
ItemsProvider callback, the
request parameter gives you access
to the current sort order. It's up to you to translate this into whatever kind of parameters are supported
by your underlying data source.
In most cases you should do this by calling
request.GetSortByProperties() to get a list of
the sort property names and directions. This will work as long as:
ISortBuilderColumn(the built-in ones do)
Property="@(x => x.Medals.Gold)"is OK, and will give the sort property name
Property="@(x => x.Width * x.Length)"is not OK, and will make
GetSortByPropertiesthrow an exception.
If you have a column whose sort expression can't be expressed as a chain of property names, then instead
GetSortByProperties, you will need to read
request.SortByAscending and use your own knowledge of the column to convert this into parameter values
for your underlying data source.