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:
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.