Question
“How do I expand or collapse all drilldowns from the preview window?”
Solution
Create a preview plugin that adds a new button to the main toolbar. When this button is clicked call the TppReport.ExpandDrillDowns or TppReport.CollapseDrillDowns as needed and regenerate the report.
Download: PreviewAndToggleExpandAll.zip
Sample Delphi code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
type TMyPreviewPlugin = class(TppPreview) private FCustomButton: TppTBXItem; procedure CustomButtonClickEvent(Sender: TObject); public procedure CreateToolbarItems; override; end; implementation uses Forms, ppPreviewIcons, ppForms, ppToolResources; procedure TMyPreviewPlugin.CreateToolbarItems; begin inherited CreateToolbarItems; FCustomButton := Toolbar.AddButton(); FCustomButton.ImageIndex := ToolImageList.AddTool('PPTEXTSEARCH'); //Add your own here. FCustomButton.OnClick := CustomButtonClickEvent; FCustomButton.AutoCheck := True; FCustomButton.Hint := 'Expand All'; end; procedure TMyPreviewPlugin.CustomButtonClickEvent(Sender: TObject); begin if (FCustomButton.Checked) then begin TppReport(Report).ExpandDrillDowns; FCustomButton.Hint := 'Collapse All'; end else begin TppReport(Report).CollapseDrillDowns; FCustomButton.Hint := 'Expand All'; end; Viewer.RegenerateReport; end; initialization TppPreviewPlugIn.Register(TMyPreviewPlugin); finalization TppPreviewPlugIn.UnRegister(TMyPreviewPlugin); end. |