Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Deleting groups from a report during run-time while preview is showing

edited June 2003 in General
Hi,
I am not able to delete groups from my report using a plug-in in the
standard report preview.
Here's what I've found out. The code below works fine when fired from a
button on a form with a TppViewer object.
ppReport1.Groups[0].Free;
ppViewer1.RegenerateReport;

If I call a similar code from a custom report plug-in in the standard RB
preview, I get an AV:

(Viewer.CurrentPage.Producer as TppReport).Groups[0].free;
Viewer.RegenerateReport;

Here's a different approach in the form with a TppViewer:

ppReport1.RemoveBand(ppReport1.Groups[0].HeaderBand);
ppReport1.RemoveGroup(ppReport1.Groups[0]);
ppViewer1.RegenerateReport;

..works fine.


Similar code for using the plug-in on a standard RB preview window:

with (Viewer.CurrentPage.Producer as TppReport) do
begin
RemoveBand(Groups[0].HeaderBand);
RemoveGroup(Groups[0]);
end;
Viewer.RegenerateReport;

When above code is executed it does not give me an AV, but the group's
header band is still showing once for each page on my report. The RemoveBand
is not working here.

What is the correct way of deleting groups from a report?

I am using D7, RB702 on Win XP.
Morten

Comments

  • edited June 2003
    Morten,

    When using the TppViewer, you can access the report component by using the
    Viewer.Report property. Your code should look something like the following:

    Viewer.Report.Groups[0].Free;
    Viewer.RegenerateReport;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2003
    Nico,
    Thanks, but that's the method that only works on a custom viewer, but not
    with the standard RB viewer.

    Please take a look at this project
    http://www22.brinkster.com/obergman/rbProject.zip which shows the standard
    preview not working, and a custom TppViewer working - both using the same
    method of freeing the group.

    Here's the code that is fired by the plugin (button on the left in the
    preview window) that generates an AV:
    = = = =
    var
    ActiveReport: TppReport;
    begin

    activeReport:= (Viewer.Currentpage.Producer as TppReport);
    //activeReport.DetailBand.Objects[0].Free; //<-- this works!

    if activeReport.GroupCount > 0 then
    activeReport.Groups[0].free;

    Viewer.RegenerateReport;
    end;
    = = = =

    Thanks,
    Morten


  • edited June 2003
    Morten,

    Freeing components inside the a call to Report.Print is not supported by
    ReportBuilder. We will research this further. A better way to handle this
    is to set the group bands' visibility to False and disable the NewPage
    property. Below is a link to an example that demonstrates hiding the group
    bands in a custom preview.

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

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2003
    Nico,
    Thanks for looking into this. Changing the visibility won't work that well
    since I need to re-generate the report with the new
    groups/fields/sorts/calculations etc. It would be really neat to have a form
    (own report designer) open on top of the preview form and apply changes to
    the report on the fly. For our users (who are not very technical adept) the
    designer that comes with RB is too advanced for them, so we simply want to
    let them select which fields to display and what to group on etc, and it
    would help them a lot if this could be visualized. Maybe support for group
    freeing could be added to the wish list.

    Thanks,
    Morten


  • edited June 2003
    Morten,

    Thanks for the suggestion. The Preview in ReportBuilder was not intended to
    be used as a designer. The archetecture of the entire ReportBuilder
    application is set up so most, or all, report design must be done before the
    report is generated. You will need to create a form with a TppViewer on it
    and make multiple calls to Report.PrintToDevices to achieve the the effect
    you are after.

    --
    Best Regards,

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