Back to Devexpress

PivotGridControl.CreateDrillDownDataSourceAsync() Method

windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridcontrol-8260667f.md

latest6.8 KB
Original Source

PivotGridControl.CreateDrillDownDataSourceAsync() Method

Returns a list of records used to calculate a summary value for the specified cell asynchronously.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

csharp
public Task<PivotDrillDownDataSource> CreateDrillDownDataSourceAsync()
vb
Public Function CreateDrillDownDataSourceAsync As Task(Of PivotDrillDownDataSource)

Returns

TypeDescription
Task<PivotDrillDownDataSource>

An asynchronous operation that returns PivotDrillDownDataSource.

|

Remarks

Cells in the Pivot Grid display summary and total summary values. Each summary and total summary value is calculated for a specific subset of records in the control’s underlying data source. These records are identified by the values of the column and row fields displayed within the column and row headers.

The CreateDrillDownDataSourceAsync method allows you to retrieve the subset of records from the control’s underlying data source, used to calculate the summary value for the current cell.

In Server and OLAP modes, the CreateDrillDownDataSourceAsync method returns only visible fields. To get hidden field values, use the method’s overloads with the customColumns parameter that allows you to specify the columns to return.

Example

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

In this example, the Pivot Grid 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 data set.

The GridControl displays the underlying records (the created PivotDrillDownDataSource) in the auxiliary DrillDownForm.

View Example

cs
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;
        }

        async void pivotGridControl1_CellClick(object sender, 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.
            dForm.DataSource = await pivot.CreateDrillDownDataSourceAsync(e.ColumnIndex, 
            e.RowIndex, 25, new List<string> { "ProductName","Quantity" });            
        }

        void Form1_Load(object sender, EventArgs e) {
            LoadDrillDownForm();
        }

        void LoadDrillDownForm() {
            dForm = new DrillDownForm();
            dForm.Show();
        }
    }
}
vb
Imports DevExpress.XtraPivotGrid
Imports System
Imports System.Collections.Generic

Namespace XtraPivotGrid_CreateDrillDownDataSourceAsync
    Partial Public Class Form1
        Inherits DevExpress.XtraEditors.XtraForm

        Private dForm As DrillDownForm
        Public Sub New()
            InitializeComponent()
            AddHandler Me.Load, AddressOf Form1_Load
            AddHandler pivotGridControl1.CellClick, AddressOf pivotGridControl1_CellClick
            ' This line of code is generated by Data Source Configuration Wizard
            linqServerModeSource1.QueryableSource = (New XtraPivotGrid_CreateDrillDownDataSourceAsync.DataClasses1DataContext()).Invoices
        End Sub
        Async Sub pivotGridControl1_CellClick(ByVal sender As Object, ByVal e As DevExpress.XtraPivotGrid.PivotCellEventArgs)
            Dim pivot As PivotGridControl = TryCast(sender, PivotGridControl)
            If dForm.IsDisposed Then
                LoadDrillDownForm()
            End If

            'Check whether an asynchronous operation is in progress.
            If Not pivot.IsAsyncInProgress Then

            ' Get the record set associated with the clicked cell.
            dForm.DataSource = Await pivot.CreateDrillDownDataSourceAsync(e.ColumnIndex, e.RowIndex, 25, New List(Of String) From {"ProductName", "Quantity"})
            End If
        End Sub
        Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
            LoadDrillDownForm()
        End Sub
        Sub LoadDrillDownForm()
            dForm = New DrillDownForm()
            dForm.Show()
        End Sub
    End Class
End Namespace

See Also

PivotGridControl Class

PivotGridControl Members

DevExpress.XtraPivotGrid Namespace