78 lines
2.3 KiB
ObjectPascal
78 lines
2.3 KiB
ObjectPascal
unit cxPivotDrillDownFormUnit;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, StdCtrls, ExtCtrls, cxCustomPivotGrid, cxStyles, cxCustomData,
|
|
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
|
|
cxGridLevel, cxClasses, cxControls, cxGridCustomView,
|
|
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
|
|
cxContainer, cxTextEdit, cxMemo, cxRichEdit, RichEdit, cxHyperLinkEdit,
|
|
cxLabel, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxDateRanges, dxScrollbarAnnotations,
|
|
dxBarBuiltInMenu,
|
|
cxGridCustomPopupMenu, cxGridPopupMenu;
|
|
|
|
type
|
|
TfrmDrillDown = class(TForm)
|
|
cxGrid1Level1: TcxGridLevel;
|
|
cxGrid1: TcxGrid;
|
|
TableView: TcxGridTableView;
|
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|
end;
|
|
|
|
procedure cxShowDrillDownDataSource(ACrossCell: TcxPivotGridCrossCell);
|
|
|
|
implementation
|
|
|
|
uses
|
|
cxSpinEdit, ShellAPI;
|
|
|
|
{$R *.dfm}
|
|
|
|
procedure cxShowDrillDownDataSource(ACrossCell: TcxPivotGridCrossCell);
|
|
var
|
|
AForm: TfrmDrillDown;
|
|
ADataSource: TcxCustomDataSource;
|
|
|
|
procedure CreateColumns(APivotGrid: TcxCustomPivotGrid; AGrid: TcxGridTableView);
|
|
var
|
|
I: Integer;
|
|
AColumn: TcxGridColumn;
|
|
AField: TcxPivotGridField;
|
|
begin
|
|
for I := 0 to TcxPivotGridCrossCellDataSource(ADataSource).FieldCount - 1 do
|
|
begin
|
|
AField := TcxPivotGridCrossCellDataSource(ADataSource).PivotGridFields[I];
|
|
AColumn := AGrid.CreateColumn;
|
|
AColumn.Caption := AField.Caption;
|
|
AColumn.Hidden := AField.Hidden;
|
|
AColumn.Visible := AField.Visible;
|
|
if (AField.UniqueName = '[Measures].[Discount]') or (AField.UniqueName = 'Discount') then
|
|
begin
|
|
AColumn.PropertiesClass := TcxSpinEditProperties;
|
|
TcxSpinEditProperties(AColumn.Properties).ValueType := vtFloat;
|
|
TcxSpinEditProperties(AColumn.Properties).DisplayFormat := '0.00';
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
begin
|
|
AForm := TfrmDrillDown.Create(nil);
|
|
try
|
|
ADataSource := ACrossCell.CreateDrillDownDataSource;
|
|
CreateColumns(ACrossCell.PivotGrid, AForm.TableView);
|
|
try
|
|
AForm.TableView.DataController.CustomDataSource := ADataSource;
|
|
AForm.TableView.ApplyBestFit();
|
|
AForm.ShowModal;
|
|
finally
|
|
ADataSource.Free;
|
|
end;
|
|
finally
|
|
AForm.Free;
|
|
end;
|
|
end;
|
|
|
|
end.
|