Skip to main content

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.

WinUI Grid - Get Started Data Operations

Sort Data

You can use the GridControl to sort data. The sample below sorts data against the Quantity and Order Date columns:

WinUI Grid - Get Started Sort Data

  1. Specify the ColumnBase.SortOrder property for the Quantity and Order Date columns to sort data against them.
  2. 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:

WinUI Grid - Get Started Group Data

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:

WinUI Grid - Get Started Filter Data

Specify the DataControlBase.FilterString property with a filter expression to apply a filter to the GridControl:

<dxg:GridControl FilterString="[OrderDate] &gt; #2021-01-01# And [Quantity] &gt; 20" ...>

Refer to the following help topic for more information: Filter Data.

See Also