PivotGridControl.SetFieldSortingAsync(PivotGridField, PivotSortOrder) Method
Sets the sort order for the specified field asynchronously.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.XtraPivotGrid.v24.2.dll
Declaration
Parameters
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. |
Returns
Type | Description |
---|---|
Task<Boolean> | An asynchronous operation that returns |
Remarks
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:
- PivotGridControl.ChangeFieldSortOrderAsync
- Toggles the sort order of the specified field asynchronously.
- PivotGridFieldBase.ChangeSortOrder
- Toggles the sort order for the current field.
Example
The example below sets the Country
‘s sort order to descending.
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";
//...
await pivotGridControl1.EndUpdateAsync();
await pivotGridControl1.SetFieldSortingAsync(fieldCountry,PivotSortOrder.Descending);
}
}
}