Skip to main content

PivotGridFieldBase.SortMode Property

Gets or sets how the field’s data is sorted.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.PivotGrid.v22.1.Core.dll

Declaration

[DefaultValue(PivotSortMode.Default)]
public PivotSortMode SortMode { get; set; }

Property Value

Type Default Description
PivotSortMode

Default

A PivotSortMode value that specifies how the field’s data is sorted.

Available values:

Name Description
Default

Sorts the field’s data by the field’s values (these are synchronized with the values from the bound data source).

Value

Sorts the field’s data by the field’s values (these are synchronized with the values from the bound data source).

DisplayText
  • Sorts the field’s data by the field’s display text (the strings displayed within the field values).
  • In OLAP mode, the data is sorted against the text generated on the server. Set the PivotGridOptionsOLAP.SortByCustomFieldValueDisplayText property to true to sort data by handling the PivotGridControl’s FieldValueDisplayText event.
  • The field is not sorted against the custom text generated on the client side (for instance, if you modify the text via the PivotGridControl.FieldValueDisplayText event).
Custom

Enables custom sorting of the field’s data using the CustomFieldSort event or the CustomServerModeSort event in OLAP mode.

Key

Sorts the field’s data by key attributes (in OLAP mode).

ID

Sorts by a level member’s ID (in OLAP mode).

None

Data is not sorted - it is displayed in the order the data source specifies. This option is in effect only in OLAP mode.

DimensionAttribute

Sorts the field’s data by the OLAP member property (in OLAP mode). Set the PivotGridFieldBase.SortByAttribute property to specify the dimension attribute.

Remarks

The SortMode property determines the algorithm used to sort the field’s data. For example, you can sort the field’s data by display text or enable custom sorting.

To sort the pivot grid field’s data by an OLAP member property, set the SortMode property to PivotSortMode.DimensionAttribute and assign the member property’s name to PivotGridFieldBase.SortByAttribute.

To apply sorting to a field, set the field’s PivotGridFieldBase.SortOrder property to PivotSortOrder.Ascending or PivotSortOrder.Descending. The field’s values are arranged in ascending or descending order according to the algorithm that is specified in the SortMode property.

To support sorting by the OLAP server’s OrderBy attribute when it is set to Key or Name, set the SortMode property to Default, and the PivotGridOptionsOLAP.SortUsingDiscoverXmlMetadata property to true.

Custom Sort Mode

Note

Custom sort mode is not supported in Optimized mode.

Set the SortMode property to Custom and handle the CustomFieldSort event to enable custom sorting.

In OLAP and server modes, handle the CustomServerModeSort event.

Refer to the platform-specific API articles for more information:

WinForms ASP.NET ASP.NET MVC WPF
CustomFieldSort CustomFieldSort CustomFieldSort CustomFieldSort
CustomServerModeSort CustomServerModeSort CustomServerModeSort CustomServerModeSort

The following code snippets (auto-collected from DevExpress Examples) contain references to the SortMode property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also