From 1e867f1d487de0d935efe919758f3de6185146ff Mon Sep 17 00:00:00 2001 From: sgwp <63001967@qq.com> Date: Tue, 22 Oct 2024 09:46:54 +0800 Subject: [PATCH] 111 --- public10/design/cxPivotDrillDownFormUnit.dfm | 46 ++++++++++++ public10/design/cxPivotDrillDownFormUnit.pas | 77 ++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 public10/design/cxPivotDrillDownFormUnit.dfm create mode 100644 public10/design/cxPivotDrillDownFormUnit.pas diff --git a/public10/design/cxPivotDrillDownFormUnit.dfm b/public10/design/cxPivotDrillDownFormUnit.dfm new file mode 100644 index 0000000..2345d34 --- /dev/null +++ b/public10/design/cxPivotDrillDownFormUnit.dfm @@ -0,0 +1,46 @@ +object frmDrillDown: TfrmDrillDown + Left = 278 + Top = 278 + ActiveControl = cxGrid1 + Caption = 'Drill Down Form' + ClientHeight = 495 + ClientWidth = 754 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poMainFormCenter + PixelsPerInch = 96 + TextHeight = 13 + object cxGrid1: TcxGrid + Left = 0 + Top = 0 + Width = 754 + Height = 495 + Align = alClient + TabOrder = 0 + ExplicitWidth = 644 + ExplicitHeight = 349 + object TableView: TcxGridTableView + Navigator.Buttons.CustomButtons = <> + ScrollbarAnnotations.CustomAnnotations = <> + DataController.Summary.DefaultGroupSummaryItems = <> + DataController.Summary.FooterSummaryItems = <> + DataController.Summary.SummaryGroups = <> + OptionsView.Footer = True + OptionsView.FooterAutoHeight = True + end + object cxGrid1Level1: TcxGridLevel + GridView = TableView + end + end + object cxGridPopupMenu1: TcxGridPopupMenu + Grid = cxGrid1 + PopupMenus = <> + Left = 208 + Top = 287 + end +end diff --git a/public10/design/cxPivotDrillDownFormUnit.pas b/public10/design/cxPivotDrillDownFormUnit.pas new file mode 100644 index 0000000..4094bd1 --- /dev/null +++ b/public10/design/cxPivotDrillDownFormUnit.pas @@ -0,0 +1,77 @@ +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, + dxSkinsCore, dxSkinsDefaultPainters, dxSkinWXI, 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.