windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridcontrol-dot-changefieldexpandedasync-x28-devexpress-dot-xtrapivotgrid-dot-pivotgridfieldbase-system-dot-boolean-x29.md
Expands or collapses all values of the specified Pivot Grid field asynchronously.
Namespace : DevExpress.XtraPivotGrid
Assembly : DevExpress.XtraPivotGrid.v25.2.dll
NuGet Package : DevExpress.Win.PivotGrid
public Task<bool> ChangeFieldExpandedAsync(
PivotGridFieldBase field,
bool expand
)
Public Function ChangeFieldExpandedAsync(
field As PivotGridFieldBase,
expand As Boolean
) As Task(Of Boolean)
| Name | Type | Description |
|---|---|---|
| field | PivotGridFieldBase |
A PivotGridFieldBase descendant that specifies the field whose values should be expanded/collapsed.
| | expand | Boolean |
true to expand field values; false to collapse them.
|
| Type | Description |
|---|---|
| Task<Boolean> |
An asynchronous operation that returns true in case of success.
|
The ChangeFieldExpandedAsync method is asynchronous. ChangeFieldExpandedAsync 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.
Use the following methods to collapse or expand all vales of the specified Pivot Grid field synchronously:
PivotGridFieldBase.CollapseAllCollapses all rows/columns that correspond to the current column field or row field.PivotGridFieldBase.ExpandAllExpands all columns/rows that correspond to the current column field or row field.
Use the following methods to collapse or expand a specific field value:
PivotGridControl.CollapseValueAsyncCollapses the specified column or row asynchronously.PivotGridControl.ExpandValueAsyncExpands the specified column or row asynchronously.PivotGridControl.CollapseValueCollapses a specific column or row that is identified by the specified values.PivotGridControl.ExpandValueExpands a specific column or row that is identified by the specified values.
You can specify whether a user can expand or collapse field values in the UI. For this, use the PivotGridFieldOptions.AllowExpand property.
The example below shows how to expand fieldCountry values asynchronously. Users cannot collapse fieldCountry values in the UI because AllowExpand is set to False.
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.ChangeFieldExpandedAsync(fieldCountry, true);
fieldCountry.Options.AllowExpand = DevExpress.Utils.DefaultBoolean.False;
}
}
}
Imports DevExpress.XtraPivotGrid
Imports System.Windows.Forms
Namespace WindowsFormsApp2
Partial Public Class Form1
Inherits Form
Public Sub New()
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()
End Sub
Private Async Sub ConfigureLayout()
pivotGridControl1.BeginUpdate()
' Create and configure Pivot Grid fields
Dim fieldCountry As PivotGridField = pivotGridControl1.Fields.Add("Country", PivotArea.ColumnArea)
fieldCountry.DataBinding = New DataSourceColumnBinding("[Customer].[Country].[Country]")
fieldCountry.Name = "fieldCountry"
'...
Await pivotGridControl1.EndUpdateAsync()
Await pivotGridControl1.ChangeFieldExpandedAsync(fieldCountry, True)
fieldCountry.Options.AllowExpand = DevExpress.Utils.DefaultBoolean.False
End Sub
End Class
End Namespace
See Also
CollapseValue(Boolean, Object[])