Skip to main content

PivotGridControl.SetFieldSortingAsync(PivotGridField, PivotSortOrder) Method

Sets the sort order for the specified field asynchronously.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v23.1.dll

NuGet Package: DevExpress.Win.PivotGrid


public Task<bool> SetFieldSortingAsync(
    PivotGridField field,
    PivotSortOrder sortOrder


Name Type Description
field PivotGridField

A PivotGridField object that specifies a field whose sort order should be changed.

sortOrder PivotSortOrder

A PivotSortOrder enumeration member that specifies the field sort order.


Type Description

An asynchronous operation that returns true in case of success.


The SetFieldSortingAsync method is asynchronous. SetFieldSortingAsync starts to execute the related operation in a background thread, and returns the Pivot Grid control. The main UI thread remains unblocked to allow the application to continue responding to user actions. Refer to the following topic for more information: Asynchronous Mode.

The PivotGridFieldBase.SortOrder property specifies the field sort order.

To toggle the field sort order, use the following methods:

Toggles the sort order of the specified field asynchronously.
Toggles the sort order for the current field.


The example below sets the Country‘s sort order to descending.

Field City with the descending sort order

using DevExpress.XtraPivotGrid;
using System.Windows.Forms;

namespace WindowsFormsApp2 {
    public partial class Form1 : Form {
        public Form1() {
            pivotGridControl1.OLAPConnectionString = "Provider=msolap;" +
                "Data Source=;" +
                "Initial Catalog=Adventure Works DW Standard Edition;" +
                "Cube Name=Adventure Works;";
            pivotGridControl1.OptionsBehavior.UseAsyncMode = true;
        async void ConfigureLayout() {
            // Create and configure Pivot Grid fields
            PivotGridField fieldCountry = pivotGridControl1.Fields.Add("Country", PivotArea.ColumnArea);
            fieldCountry.DataBinding = new DataSourceColumnBinding("[Customer].[Country].[Country]");
            fieldCountry.Name = "fieldCountry";
            await pivotGridControl1.EndUpdateAsync();

            await pivotGridControl1.SetFieldSortingAsync(fieldCountry,PivotSortOrder.Descending);
See Also