PivotGridControl.CreateDrillDownDataSourceAsync(Int32, Int32, AsyncCompletedHandler) Method
Returns a list of records used to calculate a summary value for the specified cell asynchronously.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.XtraPivotGrid.v18.2.dll
Declaration
public void CreateDrillDownDataSourceAsync(
int columnIndex,
int rowIndex,
AsyncCompletedHandler asyncCompleted
)
Parameters
Name | Type | Description |
---|---|---|
columnIndex | Int32 | A zero-based integer which identifies the visible index of the column. Pass -1 as a column index to obtain the column’s Grand Total. |
rowIndex | Int32 | A zero-based integer which identifies the visible index of the row. Pass -1 as a row index to obtain the row’s Grand Total. |
asyncCompleted | AsyncCompletedHandler | A AsyncCompletedHandler delegate referencing a method that should be executed after the operation is completed. The drill-down data source is passed to this method as a parameter. |
Remarks
The CreateDrillDownDataSourceAsync method is asynchronous. It starts executing the related operation in a background thread, and immediately returns control. The primary UI thread is not blocked, allowing the application to continue responding to end-user actions. For more information about the asynchronous mode, see Asynchronous Mode.
The drill-down data source (a PivotDrillDownDataSource instance) is passed to the asyncCompleted delegate via the result parameter. This parameter returns an AsyncOperationResult instance. Use the AsyncOperationResult.Value property to obtain the drill-down data source.
To create a drill-down data source synchronously, use the PivotGridControl.CreateDrillDownDataSource method.
Note
In OLAP mode, calling this method is equivalent to calling the PivotGridControl.CreateOLAPDrillDownDataSourceAsync method with the customColumns parameter set to null.
Note
Calling the CreateDrillDownDataSourceAsync method from the PivotGridControl.CustomSummary and PivotGridControl.CustomUnboundFieldData event handlers may result in the stack overflow exception. To provide custom cell values that require obtaining the underlying data to be calculated, handle the PivotGridControl.CustomCellValue event, and call the CreateDrillDownDataSourceAsync method in the event handler.
Example
This example shows how to use asynchronous operations that return the result.
In this example, the PivotGridControl.CellClick event is handled to generate a drill-down data source for a specific cell using the PivotGridControl.CreateDrillDownDataSourceAsync method. The AsyncCompletedHandler delegate is passed as a method parameter. The referenced method is executed after the operation is completed, allowing to obtain the result via the result parameter of the delegate. This parameter returns an AsyncOperationResult instance.
The AsyncOperationResult.Value property is used to obtain a record set associated with the clicked cell. Then, the PivotDrillDownDataSource.RowCount property is used to determine the number of records in the data source for this cell.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-use-asynchronous-operations-that-return-the-result-e4567
using System;
using System.Windows.Forms;
using DevExpress.XtraPivotGrid;
namespace XtraPivotGrid_CreateDrillDownDataSourceAsync {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
// Binds the pivot grid to data.
this.salesPersonTableAdapter.Fill(this.nwindDataSet.SalesPerson);
}
private void pivotGridControl1_CellClick(object sender,
DevExpress.XtraPivotGrid.PivotCellEventArgs e) {
PivotGridControl pivot = sender as PivotGridControl;
//Checks whether an asynchronous operation is in progress.
if (!pivot.IsAsyncInProgress)
// Gets the record set associated with the clicked cell.
// The delegate is passed to obtain this record set.
pivot.CreateDrillDownDataSourceAsync(e.ColumnIndex, e.RowIndex, result => {
// The 'result' parameter of the delegate returns an AsyncOperationResult instance.
// The AsyncOperationResult.Value property is used to obtain the record set,
// the PivotDrillDownDataSource.RowCount property is used to obtain the number
// of records in the data source.
label1.Text = "RowCount = " + ((PivotDrillDownDataSource)result.Value).RowCount;
});
}
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CreateDrillDownDataSourceAsync(Int32, Int32, AsyncCompletedHandler) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.