Skip to main content

PivotGridControl.ClearFieldSortingAsync(PivotGridField) Method

Clears field sorting asynchronously in OLAP mode.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v23.2.dll

NuGet Package: DevExpress.Win.PivotGrid

Declaration

public Task<bool> ClearFieldSortingAsync(
    PivotGridField field
)

Parameters

Name Type Description
field PivotGridField

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

Returns

Type Description
Task<Boolean>

An asynchronous operation that returns true in case of success.

Remarks

The ClearFieldSortingAsync method is asynchronous. ClearFieldSortingAsync 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.

This method switches the field sort order to the one defined on the OLAP server.

Example

The example below resets the sort order of the Country field values set by the field’s SortOrder property. SortOrder is set to Descending but the ClearFieldSortingAsync method changes the specified sort order and the Pivot Grid displays the Country field values in ascending order (the sort order defined on the server).

Changed field sort order

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

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

            await pivotGridControl1.ClearFieldSortingAsync(fieldCountry);
        }
    }
}
See Also