[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Collapse]Pivot Grid
   [Expand]Getting Started
   [Expand]Fundamentals
   [Expand]Binding to Data
   [Collapse]Data Shaping
    [Expand]Summarization
     Grouping
    [Collapse]Sorting
      Sorting Data
      Displaying Top N Values for a Field
      Sorting by Summary
    [Expand]Filtering
    [Expand]Editing
     Data Formatting
   [Expand]Data Analysis
   [Expand]Layout
   [Expand]Focus and Navigation
   [Expand]Printing and Exporting
   [Expand]Appearance
   [Expand]Design-time Features
   [Expand]Miscellaneous
   [Expand]UI Elements
   [Expand]End-User Capabilities
   [Expand]Examples
   [Expand]Member Tables
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Sorting Data

Expanded Sort Order

The PivotGridControl's data (and nested values in groups) are sorted by fields in the Column Header Area and Row Header Area. The default sort order is ascending.

To change a field’s sort order, specify the PivotGridFieldBase.SortOrder property or click the pivot grid field's header.

In the picture below, the data rows are sorted alphabetically in ascending order by the Product Name field. The data columns are sorted in ascending order by the Order Date field.

Expanded Sort Modes

The sort mode determines the attribute by which to sort field values. You can use the PivotGridFieldBase.SortMode property to specify the sort mode for each field.

When a pivot grid obtains its data from a non-OLAP data source, you can sort field values by the value itself (default mode), by the field's displayed text, or implement a custom sorting algorithm as shown in the following table:

Sort Mode Description
PivotSortMode.Value Field values are sorted in alphabetical order (for text data) or in ascending order (for numeric and date/time data).
PivotSortMode.DisplayText You can sort values by the displayed (formatted) text instead of the original field values if numeric field values are formatted in the PivotGridControl.FieldValueDisplayText event handler.
PivotSortMode.Custom The PivotGridControl.CustomFieldSort event fires. Implement a field value comparison within the event handler and set the PivotGridCustomFieldSortEventArgsBase<T>.Result value depending on the comparison result.
Note that in a server mode, the PivotGridControl.CustomServerModeSort event fires instead.

When a pivot grid obtains its data from an OLAP data source, you can sort field values by the value itself (default mode) or by the field's display text. the following OLAP-specific modes are also in effect:

Sort Mode Description
PivotSortMode.DimensionAttribute Sorts the field values by an OLAP member's property. Assign the OLAP member property name to the field's PivotGridFieldBase.SortByAttribute property. To get a list of OLAP member properties, call the PivotGridFieldBase.GetOLAPMemberProperties method.
PivotSortMode.ID Sorts by a level member's ID (in OLAP mode).
PivotSortMode.Key Sorts the field's data by key attributes (in OLAP mode).
PivotSortMode.None Data is not sorted - it is displayed in the order the data source specifies. This option is in effect only in OLAP mode.
PivotSortMode.Custom The PivotGridControl.CustomServerModeSort event fires. Implement a field value comparison within the event handler and set the PivotGridCustomFieldSortEventArgsBase<T>.Result value depending on the comparison result.

Expanded See Also

Is this topic helpful?​​​​​​​