Skip to main content
A newer version of this page is available. .

How to: Create the Underlying Data Source (Drill-Down) in an Asynchronous Operation

  • 3 minutes to read

This example performs an asynchronous operation that creates a drill-down data source for the selected PivotGrid cell and gets the operation result - the underlying data source.

In this example, the PivotGrid control is bound to the LinqServerModeSource data source and operates in server mode.

The PivotGridControl.CellClick event handler calls the PivotGridControl.CreateDrillDownDataSourceAsync method to generate a drill-down data source for the selected cell. The method parameter specifies the number of records to return. The method also specifies the columns to add to the the data set.

The GridControl displays these underlying records (the created PivotDrillDownDataSource) in the auxiliary DrillDown form.

View Example: How to Create the Underlying Data Source (Drill-Down) in an Asynchronous Operation

using DevExpress.XtraPivotGrid;
using System;
using System.Collections.Generic;

namespace XtraPivotGrid_CreateDrillDownDataSourceAsync {
    public partial class Form1 : DevExpress.XtraEditors.XtraForm
    {
        DrillDownForm dForm;
        public Form1()
        {
            InitializeComponent();
            this.Load += Form1_Load;
            pivotGridControl1.CellClick += pivotGridControl1_CellClick;
            // This line of code is generated by Data Source Configuration Wizard
            linqServerModeSource1.QueryableSource = new XtraPivotGrid_CreateDrillDownDataSourceAsync.DataClasses1DataContext().Invoices;
        }
        private void pivotGridControl1_CellClick(object sender, 
            DevExpress.XtraPivotGrid.PivotCellEventArgs e) {
            PivotGridControl pivot = sender as PivotGridControl;
            if (dForm.IsDisposed) LoadDrillDownForm();

            //Check whether an asynchronous operation is in progress.
            if (!pivot.IsAsyncInProgress)

                // Get the record set associated with the clicked cell.
                pivot.CreateDrillDownDataSourceAsync(e.ColumnIndex, e.RowIndex, 25, new List<string> { "ProductName","Quantity" }, result => {
                    // The 'result' parameter of the delegate returns an AsyncOperationResult instance.
                    // The AsyncOperationResult.Value property contains a record set.
                    dForm.DataSource = (PivotDrillDownDataSource)result.Value;
                });
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            LoadDrillDownForm();
        }
        private void LoadDrillDownForm()
        {
            dForm = new DrillDownForm();
            dForm.Show();
        }
    }
}