RTFormwork/public10/design/cxPivotDrillDownFormUnit.pas

78 lines
2.3 KiB
ObjectPascal
Raw Permalink Normal View History

2024-10-22 09:46:54 +08:00
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,
2024-11-15 17:18:34 +08:00
dxBarBuiltInMenu,
2024-10-22 09:46:54 +08:00
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.