Skip to main content
A newer version of this page is available. .

Sorting in Code

Server

To apply sorting to a column(s), use one of the following methods.

The following sample code sorts data against the Department column in ascending order.


((GridViewDataColumn)ASPxGridView1.Columns["Department"]).SortAscending();

The number of columns involved in sorting is returned by the ASPxGridBase.SortCount property. A collection of sorted columns can be accessed via the ASPxGridView.GetSortedColumns method. The column’s position among sorted columns is specified by the GridViewDataColumn.SortIndex property.

To remove sorting, do one of the following.

To clear sorting applied to ASPxGridView, call the ASPxGridBase.ClearSort method.

Client

Use the ASPxClientGridView.SortBy client method to sort data by the values of the specified data column.

To prevent data from being sorted by the values of particular columns, handle the ASPxClientGridView.ColumnSorting client event. The processed client column is identified by the event parameter’s column property. To cancel sorting, set the cancel property to true.

Note

If sorting is disabled for a column, rows cannot be grouped by this column.