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

ReportExplorer MergeMenu

edited March 2003 in General
Rb7.02
Hello
The first time I launch the report explorer in an application my
mergemenu.menuitem (help)
appears correctly.
I close the report explorer and launch it again then the menu item does not
appear.
It will never appears till I close the application and run it again.
Well it only appears the first time (sorry for my english)...
If I check in code if the reportexplorer.mergemenu is still assigned it
returns ok.
Any ideas ?

Thanks
Marc

Comments

  • edited March 2003
    A suggestion that I forgot.
    It should be nice to have a report description (ie Memo) which could be
    saved as part of the report
    Regards
    Marc
  • edited March 2003
    The report template contains an offset area that you can use to store extra
    information. As an alternative to this, if you are using a database end user
    report application, then add another field to the rbItem table and store the
    memo in that field in the table. Then provide this description at run time
    in a separate pipeline on the form for the report. This way a user can
    connect a memo in the titleband to the extra pipeline. This way you can
    leave the real pipeline that provides the data for the report connected to
    the report and not have to change the dataset that you have already created
    for the report data.

    From the Tech-Tips:

    -----------------------------------------------------
    Tech Tip: Storing Custom Information with Templates
    -----------------------------------------------------

    Question:
    ---------

    How can I store descriptive information with my report template?


    Solution:
    ---------

    1. If you are storing the templates to a database, then you can use the
    Report.Template.OnSaveEnd and OnLoadEnd events to store and load the
    custom information to appropriate data fields for the record. (This is
    the technique used by the ReportExplorer.)

    2. If you are storing templates to .rtm files, then you will need to
    store the custom information in an Offset area of the template file. The
    Report.Template object enables you do this by utilizing the
    Template.Offset property and the Template.OnLoadStart and OnLoadEnd
    events. Below is a detailed example.



    Example:
    --------
    - Create a new application.
    - Add to the main form one TButton, one TppReport and one TppDesigner.

    - Set the Designer's Report property to ppReport1.
    - Add ppTypes to the uses clause.


    type
    TForm1 = class(TForm)
    Button1: TButton;
    ppReport1: TppReport;
    ppDesigner1: TppDesigner;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    private
    procedure LoadReportStreamEvent(Sender: TObject; Stream: TStream);
    procedure SaveReportStreamEvent(Sender: TObject; Stream: TStream);

    public

    end; { class TForm1 }


    {note: use compiler directive to declare strings as 'ShortStrings'
    this is required for record structures}

    {$H-}

    {record structure used to store information inside report template }
    TmyTemplateInfo = record
    HeaderID: Integer;
    Comments: String;
    DateTime: TDateTime;

    end; {record, TppTemplateRec}

    {$H+}


    const
    cHeaderID = 12345;

    implementation


    {-------------------------------------------------}
    { TForm1.FormCreate }

    procedure TForm1.FormCreate(Sender: TObject);
    begin

    {setup Template events }
    ppReport1.Template.Format := ftASCII;
    ppReport1.Template.Offset := SizeOf(TmyTemplateInfo);
    ppReport1.Template.OnLoadStart := LoadReportStreamEvent;
    ppReport1.Template.OnSaveEnd := SaveReportStreamEvent;

    end; {procedure, FormCreate}

    {-------------------------------------------------}
    { TForm1.Button1Click }

    procedure TForm1.Button1Click(Sender: TObject);
    begin

    ppDesigner1.Show;

    end; {procedure, Button1Click}

    {--------------------------------------------------}
    { TForm1.LoadReportStreamEvent }

    procedure TForm1.LoadReportStreamEvent(Sender: TObject; Stream:
    TStream);
    var
    lTemplateInfo: TmyTemplateInfo;
    lsMessage: String;

    begin

    {read string stored in template header }
    Stream.Seek(0, soFromBeginning);
    Stream.Read(lTemplateInfo, SizeOf(TmyTemplateInfo));

    {note: if not one of the templates with our header info, then set
    Offset to 0 }
    if lTemplateInfo.HeaderID = cHeaderID then
    begin
    lsMessage := 'Reading data from template file: ' + #13#10 + #13#10
    +
    lTemplateInfo.Comments + ' (' +
    DateTimeToStr(lTemplateInfo.DateTime) + ')';

    MessageDlg(lsMessage, mtInformation, [mbOK],0);
    ppReport1.Template.Offset := SizeOf(TmyTemplateInfo);
    end
    else
    ppReport1.Template.Offset := 0;

    end; {procedure, LoadReportStreamEvent}


    {-----------------------------------------------------------------------
    -------}
    { TForm1.SaveReportStreamEvent }

    procedure TForm1.SaveReportStreamEvent(Sender: TObject; Stream:
    TStream);
    var
    lTemplateInfo: TmyTemplateInfo;
    lsMessage: String;

    begin

    lTemplateInfo.HeaderID := cHeaderID;
    lTemplateInfo.Comments := 'This comment is being stored inside the
    report template, ' + #13#10 +
    'along with the date and time written. ';
    lTemplateInfo.DateTime := Now;

    {write info to template header}
    Stream.Seek(0, soFromBeginning);
    Stream.Write(lTemplateInfo, SizeOf(TmyTemplateInfo));

    lsMessage := 'Writing data to template file: ' + #13#10 + #13#10 +
    lTemplateInfo.Comments + ' (' +
    DateTimeToStr(lTemplateInfo.DateTime) + ')';
    MessageDlg(lsMessage, mtInformation, [mbOK],0);

    end; {procedure, SaveReportStreamEvent}




    Cheers,

    Jim Bennett
    Digital Metaphors






  • edited March 2003
    Marc,

    I am not able to recreate your issue on my own machine. Using the
    RBuilder\Demos\3. EndUser\1. Report Explorer\ demo, I placed a MainMenu
    component on the form and set it to be the MergeMenu of the Report Explorer.
    I then proceded to load the Report Explorer and saw the new menu item. Next
    I closed the Report Explorer and re-loaded it. The menu item remained the
    same. Please send a small example demonstrating the problem in .zip format
    to support@digital-metaphors.com so I may research this further.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2003
    Hi,
    My RBuilder\Demos\3. EndUser\1. Report Explorer\ demo has been sent to the
    digital-metaphors support
    Thanks
    Regards
  • edited April 2003
    Hello,
    Have you got any news ?
    Regards
    Marc
  • edited April 2003
    Sorry, we're still working on it. I will let you know when I find a
    solution.

    --
    Best Regards,

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