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.
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 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 ItemsControl for display.
- MainWindow.xaml (VB: MainWindow.xaml)
- MainWindow.xaml.cs (VB: MainWindow.xaml.vb)
- DatabaseHelper.cs (VB: DatabaseHelper.vb)
(you will be redirected to DevExpress.com to submit your response)