// Creates a drilldown data source for a particular cross cell and displays its data in a form.
procedure cxShowDrillDownDataSource(ACrossCell: TcxPivotGridCrossCell);
// Creates columns in the cxGridTableView for all the pivot grid fields.
procedure CreateColumns(APivotGrid: TcxCustomPivotGrid; AGridView: TcxGridTableView);
var
I: Integer;
AField: TcxPivotGridField;
begin
for I := 0 to APivotGrid.FieldCount - 1 do
begin
AField := APivotGrid.Fields[I];
with AGridView.CreateColumn do
begin
Caption := AField.Caption;
Visible := AField.Visible;
Hidden := AField.Hidden;
end;
end;
end;
var
AForm: TForm2;
ADataSource: TcxCustomDataSource;
begin
AForm := TForm2.Create(nil);
try
CreateColumns(ACrossCell.PivotGrid, AForm.cxGrid1TableView1);
ADataSource := ACrossCell.CreateDrillDownDataSource;
try
// Links a drilldown data source to the grid抯 TableView.
AForm.cxGrid1TableView1.DataController.CustomDataSource := ADataSource;
AForm.ShowModal;
finally
ADataSource.Free;
end;
finally
AForm.Free;
end;
end;
// The pivot grid抯 OnDblClick event handler.
procedure TForm1.cxDBPivotGrid1DblClick(Sender: TObject);
var
ACrossCell: TcxPivotGridCrossCell;
begin
with cxDBPivotGrid1.HitTest do
begin
// Handles double-clicks on data cells
if HitAtDataCell then
begin
// Determines a cross cell which corresponds to the data cell being clicked.