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

From Previewer want ability to load designer...

edited December 2002 in End User
I've registered my own report previewer. Now, I want to add a button to the
toolbar that will load the report designer with the currently active report
and data pipelines. Also, when the designer closes, if the report design has
changed the report needs to re-draw itself. How should I go about this?

Comments

  • edited December 2002
    We don't recommend trying this, but it may be possible. Use the report
    designer at it is designed in the workspace which has the 4 elements of the
    report equation:

    Data -> Calculations -> Design -> Preview

    Are you using the TppPreview plug-in architecture, or are you replacing the
    preview form itself? If you are descending from TppPreview, then you can
    create a button as shown in this example.

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

    However, if you have a custom preview form replacement you aren't using the
    TppPreview plugin architecture, you can ignore the above approach.

    The problem is that all of this is going to happen inside of a call to
    Report.Print. What the best way to reprint is to call Report.Print again
    after the first Report.Print execution has finished. But that isn't
    possible because the preview form is created in the producer as part of the
    print process. You can try otherwise, but not sure what will happen. Put a
    designer on the preview form. Then you can connect the report to that
    designer. Call Designer.ShowModal. When the designer closes, you can call
    Viewer.Reset and Viewer.FirstPage after the call to ShowModal in your
    button's event handler. That should cause the report to regenerate the first
    page and send it to the screen device. The reason this might not work is
    that the report has a cache manager and when Report.Print is called, a
    footprint for all of the components in the report is saved. If this changes
    while the report is running (ie, you add or remove a component) then it may
    not generate correctly.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited December 2002
    I'll work with your suggestions. Thank you...

    Some questions, though... Can I hide the preview tab in the designer? I'm
    descending from TppPreview and the preview window shows my "Design" button
    again, which is not good, ie, I can repeatedly open new design windows...
    Alternatively, within the TppPReview descendent, can I determine if I'm in a
    report or in the preview window of the designer?

    Reports in my app are stored in a database. In my designer I don't want the
    user to be able to open a new report, or save the report under a different
    name. I want them to control fonts, add design elements and link to data
    fields, things like that... Nothing too involved... How do I go about
    chopping out functionality to that degree?

  • edited December 2002
    A related question... I have the design button working within the
    report.print previewer. That is, the design window comes up with a
    .Showmodal. If I make a change in the designer, though, then close (without
    saving), the report design is not saved (to the database) and I am not
    warned about losing my changes. Is there a way to popup a dialog about "Do
    you want to discard changes?"

  • edited December 2002
    Ok... one other question... after the designer.showModal, how can I tell if
    the user saved changes in the designer... I don't want to try to reset the
    report to the first page if the user doesn't alter the report design.

  • edited December 2002
    So far I haven't been able to get the preview to update after changes to the
    design, just as you said might be a problem...

    If this method is not recommended, what method is? I've been trying to
    understand the best way to let users make minor changes to reports. Rather
    than print then design, should I have the options of print and design side
    by side (as buttons on my form, say), then if the user clicks design load
    the designer with the report in question?

    The reason I am having a conceptual problem with this... end-users don't
    need a designer, but they do need the reports. So, the ability to see
    reports is generally programmed before the ability for end-users to design
    reports. So, when I wanted to add the ability for users to make changes to
    existing reports, it seemed logical to do that from within the existing
    architecture rather than add a separate button/menu option to design _rather
    than_ preview. I use one previewer throughout my application, but I acccess
    reports from many different forms, so it sounds like I will have to modify
    those many different forms to bring up either the previewer or designer...
    Is that correct?


  • edited December 2002
    How many messages am I gonna line up on this thread???

    Only some of my users should be allowed to change report designs. Would it
    be reasonable to use a TppDesigner instead of a TppReport, and always load
    the report in preview mode for all users. Some users would see the design
    tab, some would not. What I'm trying to avoid is the need to make changes to
    every form that gives access point to reports, ie, I don't want to have both
    a print button and a design button. What I'm thinking is the existing print
    buttons would load a TppDesigner in preview mode.

    Thanks in advance.

  • edited December 2002
    > How many messages am I gonna line up on this thread???

    As many as you want:)

    The designer component is what you'll want to give the end user with only
    the design and preview tabs. You can scale the designer down. You can use
    the ShowComponents property of the designer if you want to not show all the
    controls to the user. You can also hide the menus in the designer. Here is
    an example of a bare bones designer by also removing the toolbars in code:

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


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited December 2002
    Oh, there is this cool property I forgot to mention on the Designer
    component called TabsVisible. Set this to False. Hit F1 on this property to
    see the help.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited December 2002
    In some cases I want the preview tab to be visible when I first call
    designer.showModal. How do I do that?

  • edited December 2002
    I worded that incorrectly... I meant that I want the preview page to be
    displayed (ie, report preview) when designer.showModal is called. I think I
    can do it with

    TppDesignerWindow (ppDesigner1.Form).pgcDesigner.ActivePageIndex := 1;

    in the onShow event of the designer.

    Then, my speedbutton to "Design Report" will simply change the
    ActivePageIndex to 0. Some users will not be allowed to design reports, so
    they won't get the "Design Report" button, and will never see the designer.

  • edited December 2002
    In the onShow event of the designer I change the ActivePageIndex, as stated
    below... The previewer comes up empty, though. If I then click on the design
    tab, then back on the preview tab, my report is there... How can I have the
    designer come up initially with the preview tab displayed and the report
    ready to view?

  • edited December 2002
    In the Designer's OnShow event, call

    uses
    ppDsgner;
    ...
    TppDesignerWindow(ppDesigner1.Form).Notebook.SelectNextPage(True);

    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited December 2002
    Thanks... SelectNextPage worked.

    I have one remaining issue... If I make a change in the designer (like
    change the text of a label), then close (without saving), the report design
    is not saved (to the MS SQL database, in my case) and I am not warned about
    losing my changes. Is there a way to popup a dialog about "Do you want to
    discard changes?"

  • edited December 2002
    Are you running RB 6 or earlier? There was an issue in RB 6 where the
    modified property was not getting set. If you are using a standalone
    designer and no report explorer, then you have to code it. The report
    explorer has the save option built in, but the standalone designer component
    doesn't. In this example I used the OnCloseQuery event of the designer to
    save to file, but you could also save to database.

    procedure TForm1.ppDesigner1CloseQuery(Sender: TObject;
    var CanClose: Boolean);
    begin

    if (ppDesigner1.Report.Modified) then
    if SaveDialog1.Execute then
    begin
    ppReport1.Template.FileName := SaveDialog1.FileName;
    ppReport1.Template.SaveToFile;
    end;

    end;

    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited December 2002
    Something a bit odd is happening on one of my reports...

    In the OnShow for the TppDesigner I do a SelectNextPage to have the Preview
    page shown initially. If I then click on the Design tab, then close the
    window, the Report.modified property is true, and (using my code) am asked
    if I want to save changes (even though I haven't made any).

    It's possible that I am setting the visibility of components at run-time, or
    some other sort of conditional formatting of components on the report. I
    guess what needs to happen is I need to make sure modified is false when the
    designer first comes up. Any way to do that?

  • edited December 2002
    Set Designer.Report.Modified := False after it has loaded and the designer
    is shown. This shouldn't be a problem in RB 7. There was a known issue in
    older versions where setting the units (internal initialization code) in the
    designer was causing modified to get set to true. If you have an older
    version, then upgrade to RB 7 to see if that fixes the problem.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited December 2002
    I have RB 7. What I think is happening is that my report is being modified
    at run-time before the report is shown, and that is setting modified to
    true... In one case, I have several subreports defined in the report. When
    the report loads I free and nil some of the subreports depending on run-time
    variables.

    I am now setting modified to false during the onShow and that seems to fix
    the problem, although now I am concerned that if the user wants to change
    the design of this report he will not have all the subreports available and
    he might accidentally save a changed report (minus some important
    subreports) over a good report (which includes all subreports). That's
    something I'll have to re-code.

    Anyway, I think the mystery is solved, and what remains is something I have
    to re-design. Thanks for your help.


This discussion has been closed.