PivotCellBaseEventArgs.CreateDrillDownDataSource() Method
Returns a list of records used to calculate a value for the current cell.
Namespace: DevExpress.Xpf.PivotGrid
Assembly: DevExpress.Xpf.PivotGrid.v24.2.dll
NuGet Package: DevExpress.Wpf.PivotGrid
#Declaration
public PivotDrillDownDataSource CreateDrillDownDataSource()
#Returns
Type | Description |
---|---|
Pivot |
A Pivot |
#Example
This example demonstrates how to obtain records from the control’s underlying data source for a selected cell or multiple selected cells.
- Click a cell to show the underlying data in the GridControl.
- Select multiple cells to show the order IDs of the orders summarized in the selected cells. Order IDs are displayed as buttons in the ItemsControl control.
Note
The complete sample project How to: Use the Create
The PivotGridControl.CellClick event is handled in XAML with the DXEvent DevExpress MVVM framework extension. When the cell is clicked, the CreateDrillDownDataSource
method returns the PivotDrillDownDataSource instance that contains underlying data for the current cell. The PivotDrillDownDataSource object is used as the GridControl’s data source (it is assigned to the GridControl.ItemsSource property.)
The PivotGridControl.CellSelectionChanged event is handled in the code-behind. The coordinates of the selected cells are obtained with the PivotGridControl.MultiSelection.SelectedCells notation. For each (X, Y) pair of cell coordinates the PivotGridControl.GetCellInfo method returns an object whose CreateDrillDownDataSource
method yields the PivotDrillDownDataSource object. The PivotDrillDownDataSource exposes an enumerator and supports an iteration over a collection of the PivotDrillDownDataRow objects. The PivotDrillDownDataRow.ListSourceRowIndex property value is an index of the record in the original data source, so the source record is also available and can be added to a collection. The resulting collection is bound to the ItemsControl.
using DevExpress.Xpf.Core;
using DevExpress.Xpf.PivotGrid;
using System.Collections.ObjectModel;
using System.Windows;
namespace WpfDrillDownDataSourceExample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///
public partial class MainWindow : ThemedWindow
{
public ObservableCollection<MyOrderRow> OrderSourceList { get; set; }
public ObservableCollection<MyOrderRow> OrderDrillDownList { get; set; }
public MainWindow()
{
InitializeComponent();
OrderSourceList = DatabaseHelper.CreateData();
pivotGridControl1.DataSource = OrderSourceList;
pivotGridControl1.SelectMode = SelectMode.MultiSelection;
}
private void PivotGridControl1_CellSelectionChanged(object sender, RoutedEventArgs e)
{
OrderDrillDownList = new ObservableCollection<MyOrderRow>();
foreach (System.Drawing.Point cellPoint in pivotGridControl1.MultiSelection.SelectedCells)
{
foreach (PivotDrillDownDataRow record in pivotGridControl1.GetCellInfo(cellPoint.X, cellPoint.Y).CreateDrillDownDataSource())
{
OrderDrillDownList.Add(OrderSourceList[record.ListSourceRowIndex]);
}
}
lvOrders.ItemsSource = OrderDrillDownList;
}
private void ThemedWindow_Loaded(object sender, RoutedEventArgs e)
{
pivotGridControl1.BestFitArea = DevExpress.Xpf.PivotGrid.FieldBestFitArea.FieldHeader;
pivotGridControl1.BestFit();
}
}
}