GridColumn.SortOrder Property
Gets or sets the column’s sort order. This is a bindable property.
Namespace: DevExpress.Maui.DataGrid
Assembly: DevExpress.Maui.DataGrid.dll
NuGet Package: DevExpress.Maui.DataGrid
Declaration
public DataSortOrder SortOrder { get; set; }
Property Value
Type | Description |
---|---|
DataSortOrder | A value that specifies the sort order for grid column data. |
Available values:
Name | Description |
---|---|
None | Data is not sorted. |
Ascending | Sorts data in ascending order. |
Descending | Sorts data in descending order. |
Remarks
Use the SortOrder
property value to sort data by the column’s values or determine which sort order is currently applied to the column.
- Single-Column Sorting (Default)
- The grid allows data sorting by a single column only if the DataGridView.SortMode property is set to Single.
In this case, when a column’s
SortOrder
is changed, the grid discards the previously applied sorting by another column and sets that column’sSortOrder
property to None. - Multi-Column Sorting
- The grid supports multi-column sorting if the DataGridView.SortMode property is set to Multiple.
When a column’s
SortOrder
is changed, the grid does not clear previously applied sorting and uses the new sort order as an additional condition to sort data. To specify the sort sequence applied to columns, use the GridColumn.SortIndex of these columns.
Another way to sort data in the grid is to call the DataGridView.SortBy method.
To specify whether the grid should sort data by cell values or display text, use the GridColumn.SortMode property.
To prevent users from sorting data, use the DataGridView.AllowSort and GridColumn.AllowSort properties.
To cancel sorting, use the DataGridView.ClearSorting method.
Example
The following example sorts the Employee and Birth Date column data in ascending order:
<dxg:DataGridView SortMode="Multiple" ...>
<dxg:DataGridView.Columns>
<dxg:TemplateColumn FieldName="Name"
x:Name="EmployeeNameColumn"
Caption="Employee"
SortIndex="0"
SortOrder="Ascending"
SortMode="DisplayText">
<!--...-->
</dxg:TemplateColumn>
<dxg:DateColumn FieldName="BirthDate"
x:Name="BirthDateColumn"
SortIndex="1"
SortOrder="Ascending"
SortMode="Value"/>
</dxg:DataGridView.Columns>
</dxg:DataGridView>