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

Obtaining Underlying Data

  • 3 minutes to read

The Pivot Grid converts lengthy table data into compact reports that display summarized data. Cells display summaries calculated against data field(s) for a subset of the records in the pivot grid’s data source. All records from this subset have matching values in a column field(s) and row field(s). These values are identified by column and row headers.

pivotgrid_vs_grid

To get the list of data source records for an individual cell, use the PivotGridControl.CreateDrillDownDataSource method.

Example: How to Obtain Underlying Data

The PivotGridControl supports the drill-down capability, which enables you to retrieve a list of records that can be used to calculate a particular summary. To obtain drill-down data, use the PivotGridControl‘s PivotCellBaseEventArgs.CreateDrillDownDataSource method. Its parameters completely identify a summary cell.

In this example, an end-user can view records from the control’s underlying data source, associated with a summary cell, by double-clicking it. The obtained data is displayed by the DXGrid within a popup window.

using DevExpress.Mvvm;
using DevExpress.Mvvm.DataAnnotations;
using DevExpress.Mvvm.POCO;
using DevExpress.Xpf.PivotGrid;
using HowtoObtainUnderlyingData.NwindDataSetTableAdapters;

namespace HowtoObtainUnderlyingData {
    [POCOViewModel]
    public class ViewModel {
        NwindDataSet.SalesPersonDataTable salesPersonDataTable = new NwindDataSet.SalesPersonDataTable();
        SalesPersonTableAdapter salesPersonDataAdapter = new SalesPersonTableAdapter();

        public NwindDataSet.SalesPersonDataTable DataSource { get { return salesPersonDataTable; } }

        protected ViewModel() {
            salesPersonDataAdapter.Fill(salesPersonDataTable);
        }

        public void ShowDrillDownData(CellInfo cellInfo) {
            this.GetService<IDialogService>().ShowDialog(MessageButton.OK, "Drill Down Results", cellInfo);
        }
    }
}