Expand or Collapse Groups in code

How does one collapse all or expand all groups in a report preview with code? I have a report in a frxpreview 'form' and I want to emulate the context menu popup functionality available to collapse or expand all groups in the 'regular' report preview.

Thanks,

Dennis

Comments

  • gpigpi
    edited 5:33AM
    procedure TForm1.Button1Click(Sender: TObject);
    var
      l: TList;
      i: Integer;
      c: TfrxComponent;
    begin
      Preview.Lock;
      l := Report.AllObjects;
      for i := 0 to l.Count - 1 do
      begin
        c := l[i];
        if (c is TfrxGroupHeader) and TfrxGroupHeader(c).DrillDown then
          TfrxGroupHeader(c).ExpandDrillDown := True;
      end;
      Report.DrillState.Clear;
      Preview.RefreshReport;
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    var
      l: TList;
      i: Integer;
      c: TfrxComponent;
    begin
      Preview.Lock;
      l := Report.AllObjects;
      for i := 0 to l.Count - 1 do
      begin
        c := l[i];
        if (c is TfrxGroupHeader) and TfrxGroupHeader(c).DrillDown then
          TfrxGroupHeader(c).ExpandDrillDown := False;
      end;
      Report.DrillState.Clear;
      Preview.RefreshReport;
      Preview.SetPosition(0,0);
    end;
    
  • edited 5:33AM
    Thanks, 'gpi'. Just what I needed.

    Cheers,

    Dennis
  • edited July 2014
    Can anyone give me the Pascal equilvalenbt of this code??

    gpi wrote: »
    procedure TForm1.Button1Click(Sender: TObject);
    var
      l: TList;
      i: Integer;
      c: TfrxComponent;
    begin
      Preview.Lock;
      l := Report.AllObjects;
      for i := 0 to l.Count - 1 do
      begin
        c := l[i];
        if (c is TfrxGroupHeader) and TfrxGroupHeader(c).DrillDown then
          TfrxGroupHeader(c).ExpandDrillDown := True;
      end;
      Report.DrillState.Clear;
      Preview.RefreshReport;
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    var
      l: TList;
      i: Integer;
      c: TfrxComponent;
    begin
      Preview.Lock;
      l := Report.AllObjects;
      for i := 0 to l.Count - 1 do
      begin
        c := l[i];
        if (c is TfrxGroupHeader) and TfrxGroupHeader(c).DrillDown then
          TfrxGroupHeader(c).ExpandDrillDown := False;
      end;
      Report.DrillState.Clear;
      Preview.RefreshReport;
      Preview.SetPosition(0,0);
    end;
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.