[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Chart Control
  [Collapse]Pivot Grid
   [Expand]Getting Started
   [Expand]Binding to Data
   [Collapse]Data Shaping
      Data Sorting
      Display Top N Values
      Sorting by Summary
   [Expand]Data Analysis
   [Expand]Data Formatting
   [Expand]Design-Time Features
   [Expand]UI Elements
   [Expand]End-User Capabilities
   [Expand]Member Tables
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[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]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Data Sorting

The Pivot Grid allows its data to be sorted by an unlimited number of fields. To enable data sorting, set the field's PivotGridFieldOptions.AllowSort property to 'True'. If this property is set to 'Default', the field's behavior is controlled by the ASPxPivotGrid's PivotGridOptionsCustomization.AllowSort option.

Expanded Sort Order

Data within the ASPxPivotGrid 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 child groups are also sorted. The order in which field values are sorted is specified by a field's PivotGridFieldBase.SortOrder property. End-users can toggle the sort order by clicking a field's header.

Expanded Sort Modes

Field values can be sorted by values, display text, properties or using a custom sorting algorithm. A field's sorting mode is specified by the PivotGridFieldBase.SortMode property. By default, it is set to PivotSortMode.Default, which is currently the same option as PivotSortMode.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 PivotGridFieldBase.SortMode property to PivotSortMode.DisplayText. This can be useful when field values are numeric, and they are specifically formatted within the ASPxPivotGrid.FieldValueDisplayText event handler.

To sort values using custom rules, set the field's PivotGridFieldBase.SortMode property to PivotSortMode.Custom, and handle the ASPxPivotGrid.CustomFieldSort event to implement the required sorting logic. In OLAP and server mode, handle the ASPxPivotGrid.CustomServerModeSort event to improve performance.

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

Expanded Example: How to Implement Sort by Summary Feature

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E1878.

This example demonstrates how to sort values of the 'Product Name' column field by summary values calculated against the 'Quantity' data field. To do this, assign the 'Quantity' field name the 'ProductName' field's PivotGridFieldSortBySummaryInfo.FieldName property. As a result, the values is arranged in the order specified by summary values.

Expanded See Also

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