Home Subreports

Drill down multiple lines simultaneously

edited June 2006 in Subreports
Hi,

I have a report with a sub-report. I can drill down on the sub-report, but
when I do I want to Expand All. And when I close the drill down I want all
of them to close. When setting Expand All though you can't click on
drilldown label anymore.

Is there possibly an event I can catch when expanding one line and then
expand all on my own without setting Expand All. Or maybe any other
solution.

Regards,
Duan

Comments

  • edited June 2006
    Hi Duan,

    Take a look at the following article. Also the example below may be of some
    help.

    http://www.digital-metaphors.com/tips/drilldownsubreportmanualcontrol.zip

    ------------------------------------------------------------------
    Tech Tip: How can I preview a fully expanded Drill-down Subreport
    report and allow my users to selectively collapse subreports?
    ------------------------------------------------------------------

    Problem: When a TppSubReport's ExpandAll property is set to True, the
    DrillDownComponent is no longer "hot". This is because, as a performance
    issue, it is faster to remove the drill-down functionality and reset the
    report than it would be to create an unknown number of
    TppDrillDownExpansions for all the subreport instances in the report.
    Normally this is not a problem as, if you wish to collapse the drill-downs,
    you can set ExpandAll to false, and the subreports will all collapse.

    However, if you want to preview your report in an initially expanded state
    and then allow the user to collapse certain subreports, a work-around is
    needed...

    We will be using Demo report #152 for this, so open dm0152.pas in
    ReportBuilder's \Demos\1. Reports\ directory.

    Add the following:

    1. In the Uses clause, add ppTypes.
    2. In the Private section of Tfrm0152 add:

    FSubreportCount: Integer;
    FExpansionComplete: Boolean;

    3. Also in the Private section add:

    procedure CreateExpansions(aCount: Integer);

    4. For the implementation of this new method add the following:

    procedure Tfrm0152.CreateExpansions(aCount: Integer);
    var
    liCounter: Integer;
    begin
    for liCounter := 0 to aCount - 1 do
    begin
    ppOrderDetailSubReport1.AddExpansion(liCounter);
    end;
    end;

    5. Initialize your private fields in ppOrderDetail's BeforePrint event:

    FSubreportCount := 0;
    FExpansionComplete := False;

    6. Add this line to ppOrderDetailSubreport1's OnPrint event:

    if not ((ppOrderDetailSubreport1.Overflow) and (FExpansionComplete)) then
    Inc(FSubreportCount);

    7. Set ppOrderDetail's PassSetting property to psTwoPass.
    8. Add the following to ppOrderDetail's OnEndFirstPass event handler:

    if not FExpansionComplete then
    begin
    CreateExpansions(FSubreportCount);
    ppOrderDetail.ResetFromPageNo(1);
    ppOrderDetail.PassSetting := psOnePass;
    FExpansionComplete := True;
    end;


    Basically we make the report a two-pass report, using the first pass to
    count the number of subreports. When we finish the first pass, we add an
    Expansion for each of the subreports - this has the effect of simulating
    that the user has clicked all of the collapsed subreports, thereby expanding
    them, but leaving them all "hot".
    The report is now displayed as fully expanded, and the user can click
    subreports to collapse them.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.