Lesson 3: Sort, Group, and Filter Data
- 2 minutes to read
This tutorial demonstrates how to sort data in the GridControl, group data against a column, and create filters.
Sort Data
You can use the GridControl to sort data. The sample below sorts data against the Quantity and Order Date columns:
- Specify the ColumnBase.SortOrder property for the Quantity and Order Date columns to sort data against them.
- Specify the ColumnBase.SortIndex property for these columns to set the sort priority.
<dxg:GridTextColumn FieldName="Quantity" SortOrder="Ascending" SortIndex="1"/>
<dxg:GridDateColumn FieldName="OrderDate" SortOrder="Descending" SortIndex="0"/>
Refer to the following help topic for more information: Sort Data.
Group Data
You can use the GridControl to group data. The sample below groups data against the Product Name column:
Specify the ColumnBase.GroupIndex property for the Product Name column to group data against this column:
<dxg:GridTextColumn FieldName="ProductName" GroupIndex="0"/>
Refer to the following help topic for more information: Group Data.
Filter Data
You can use the GridControl to filter data. The sample below applies a filter to display records from the beginning of 2021 with Quantity over 20:
Specify the DataControlBase.FilterString property with a filter expression to apply a filter to the GridControl:
<dxg:GridControl FilterString="[OrderDate] > #2021-01-01# And [Quantity] > 20" ...>
Refer to the following help topic for more information: Filter Data.