Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Site Navigation and Layout
  [Expand]File Management
  [Expand]Multi-Use Site Controls
  [Expand]Scheduler
  [Expand]HTML Editor
  [Collapse]Pivot Grid
   [Expand]Getting Started
   [Expand]Fundamentals
   [Expand]Binding to Data
   [Collapse]Data Shaping
    [Expand]Aggregation
     Grouping
    [Collapse]Sorting
      Data Sorting
      Display Top N Values
      Sorting by Summary
    [Expand]Filtering
   [Expand]Data Analysis
   [Expand]Data Formatting
   [Expand]Layout
   [Expand]Appearance
   [Expand]Data Export
   [Expand]Design-Time Features
   [Expand]UI Elements
   [Expand]Examples
   [Expand]End-User Capabilities
   [Expand]Member Tables
  [Expand]Tree List
  [Expand]Gauges
  [Expand]Data Editors
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [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]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[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 Sort Data by a Column's Values in Code

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

How would you rate this topic?​​​​​​​