Skip to main content

Data Sorting

  • 2 minutes to read

The Pivot Grid allows its data to be sorted by an unlimited number of fields. To enable data sorting, set the field’s PivotGridField.AllowSort property to true.

Sort Order

Data within the DXPivotGrid is always sorted against the fields displayed within the Column Header Area and Row Header Area. By default, the values are sorted in ascending order. If values are displayed hierarchically, field values in the nested groups are also sorted. The order in which field values are sorted is specified by a field’s PivotGridField.SortOrder property.

End-users can toggle the sort order by clicking a field’s header.

pivotgrid_sorting

Sort Modes

Field values can be sorted by values, display text or using a custom sorting algorithm. A field’s sorting mode is specified by the PivotGridField.SortMode property. By default, it is set to FieldSortMode.Default, which is the same option as the FieldSortMode.Value. Field values are sorted in alphabetical order (for text data) and in order of magnitude (for numeric and date/time data).

To sort field values by display text, set the PivotGridField.SortMode property to FieldSortMode.DisplayText. This can be useful when field values are numeric, and they are specifically formatted within the PivotGridControl.FieldValueDisplayText event handler.

To sort values using custom rules, set the field’s PivotGridField.SortMode property to FieldSortMode.Custom, and handle the PivotGridControl.CustomFieldSort event to implement the required sorting logic. In OLAP and server mode, handle the PivotGridControl.CustomServerModeSort event to improve a performance.

In OLAP mode, you can sort pivot grid field data by OLAP member properties. Set the field’s PivotGridField.SortMode property to FieldSortMode.DimensionAttribute and assign a property name to the field’s PivotGridField.SortByAttribute property. To get a list of field properties, call the PivotGridField.GetOlapMemberProperties method.

See Also