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

Preview - refresh question

edited March 2012 in General
Hi,

I use a custom preview window that allows the user to change some things
either in the underlying table or in the formatting of the report.

See here:
http://www.beckersoft.de/screenshots/Clip1.jpg

After these changes the report should be created again.
Now my question: how can I prevent that the preview window closes and
reopens? I would like to get a smooth "refresh".

I tried "viewer.regenarate", but it always closes the preview first.

Should I use a ppViewer component?

Thanks for helping.

Regards Uli

Comments

  • edited March 2012
    Hi Uli,

    I'm a bit unclear about what you mean by "closes the preview first". In
    my quick testing with the built-in preview (and the Print button calling
    Viewer.RegenerateReport rather than Print), the report was successfully
    regenerated with the preview window closing and very little flicker.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2012
    Nico,


    I guess you meant "without the preview window closing"?

    You are right. The closing of the preview was caused by another print
    call, I used during some preparations of the new print.

    I removed that and yes: the preview stayed opened.
    But now I have the problem that I am not able to set a PageBreak to
    visible when regenerating the report.

    procedure TWizBefundForm.ppDetailBand3BeforePrint(Sender: TObject); begin if ApplyPageBreakBefund then PageBreakBefund.Visible := Token3TableBefundParserToken3ID.asInteger = FLastBefundTokenID else PageBreakBefund.Visible := false; ...

    Is it possible that the BeforePrint event of the detail band doesn't
    fire during regeneration?

    Thanks.
  • edited March 2012
    Hi Uli,

    The BeforePrint event should fire.

    If you place a break point inside the detail band BeforePrint, is it not
    firing? In my test example I created earlier, this event fires
    correctly and toggles the visibility of a TppPageBreak component as
    expected.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2012
    Nico,


    Sorry about the confusion.

    Again you are right. It fires, but due to a condition which never could
    be true, the pagebreak stayed at visible = false.

    The reason for the wrong value in this condition is that my calculations
    take place in the BeforePrint of the REPORT. And this event doesn't seem
    to be fired when regenarating. Is that true?

    Anyway no problem - I can move this calculation.

    Thanks a lot for your help

    Update:

    After the change I get an endless loop in the OnBeforePrint of the
    DetailBand when PageBreak.visible = true on the first regeneration.
    After cancelling the next toggles work fine. Looks quite odd.

    I'll investigate further what can cause this behaviour.

    Regards Uli
  • edited March 2012
    I removed all event handlers of the report.

    The report has 3 subreports, in one of them a PageBreak is placed.

    PageBreak.visible := true | Report prints fine
    PageBreak.visible := false | Report prints fine

    PageBreak.visible := false| Report prints fine
    PageBreak.visible := true| Regenarating fails (endless loop in detail band)
    Previewer.cancel := Preview is fine
    Further toggles work fine.

    Any idea?

    Thanks and regards Uli
  • edited March 2012
    Hi Uli,

    I would need to see an example of this in action to understand what is
    happening. As a test, try first printing the report with the PageBreak
    visible, then regenerate it with it hidden. Does that still give an
    infinite report?

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2012
    Hi Nico,


    OK, what exactly do you need?


    No, in this case everything works fine and as expected.

    1.
    PageBreak.visible := true;
    Run Report: ok
    PageBreak.visible := false;
    Regenerate Report: ok
    from here any toggle works fine

    2.
    PageBreak.visible := false;
    Run Report: ok
    PageBreak.visible := true;
    Regenerate Report: fails (infinitive details)

    2.
    PageBreak.visible := false;
    Run Report: ok
    PageBreak.visible := false;
    Regenerate Report: ok
    PageBreak.visible := true;
    Regenerate Report: ok (!)
    from here any toggle works fine

    Hope that helps. Thanks and regards Uli
  • edited March 2012
    Hi Uli,

    Try resetting the Report object and the Report.Engine before calling
    RegenerateReport on the viewer. In my testing this solved the issue
    when moving from no pagebreak to pagebreak.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2012
    Hi Nico,


    Thanks a lot. Works like a charm now with very little flickering.

    Best regards Uli
This discussion has been closed.