Saving to database
I want to save/load reports to/from a databases, but I don't want to use the
Explorer. I've basically built my own explorer and every thing seems to be
working OK as far as opening reports is concerned (loading the report from a
blob field into the report template, opening this in the designer etc).
I've also configured the Report.Template.DatabaseSettings.DataPipeLine to
point to a dataset where it can save and insert reports and new reports...
However, when saving new reports, the designer doesn't seem to set any of
the item_type, modified fields etc. that used to be set by the RbExplorer...
So, I'm wondering how I can set those fields. It seems like I might be able
to use the OnCustomSave and OnCustomLoad events for the Report Designer, but
if I do this, how do I know whether the user is Saving a report or Exporting
a Data Module layout (so that I can set the item_type appropriately)?
--
Best Regards,
James Crosswell
Software Engineer
Microforge.net Limited
http://www.microforge.net
Explorer. I've basically built my own explorer and every thing seems to be
working OK as far as opening reports is concerned (loading the report from a
blob field into the report template, opening this in the designer etc).
I've also configured the Report.Template.DatabaseSettings.DataPipeLine to
point to a dataset where it can save and insert reports and new reports...
However, when saving new reports, the designer doesn't seem to set any of
the item_type, modified fields etc. that used to be set by the RbExplorer...
So, I'm wondering how I can set those fields. It seems like I might be able
to use the OnCustomSave and OnCustomLoad events for the Report Designer, but
if I do this, how do I know whether the user is Saving a report or Exporting
a Data Module layout (so that I can set the item_type appropriately)?
--
Best Regards,
James Crosswell
Software Engineer
Microforge.net Limited
http://www.microforge.net
This discussion has been closed.
Comments
You are going to want to use the OnSaveStart and OnSaveEnd events of the
template to update these other fields in your database. This is the way the
report explorer does it as well. Check out the article below on
implementing and using these events.
----------------------------------------------
Tech Tip: Using Template Events
----------------------------------------------
The Report.Template object has several events that can be used for
customizing what happens when a report is loaded or saved:
- OnLoadStart
- OnLoadEnd
- OnNew
- OnSaveStart
- OnSaveEnd
The OnLoadEnd and OnNew events are often used to perform actions related
to report and data initialization.
The OnSaveEnd event is often used to save additional descriptive
("meta") data to the database each time the report is saved.
Example:
The Report.Template events are public and therefore must be assigned at
run-time.
1. In the private section of your form declaration you can declare an
event-handler method:
TForm = class(TForm)
private
procedure myTemplateOnLoadEndEvent(Sender: TObject);
public
end;
2. In the Form.OnCreate event, you can assign the event-handler to the
event:
procedure TForm1.FormCreate(Sender: TObject);
begin
ppReport1.Template.OnLoadEnd := myTemplateOnLoadEndEvent;
end;
3. Implement the event-handler method:
procedure TForm1.myTemplateOnLoadEndEvent(Sender: TObject);
begin
{add code here to initial the report or data, etc. }
ppReport1.PrinterSetup.MarginTop := 0.5;
end;
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
That seems to work - still a few little glitches to smooth over, but should
all work out in the end..
PS: Is there some way to tell which page of the designer is active (Data,
Calc etc)? If I could do that, then I could filter the list of items that
show in the Import/Export dialog to show only relevant stuff....
--
Best Regards,
James Crosswell
Software Engineer
Microforge.net Limited
http://www.microforge.net
Try using the TppDesigner.Notebook property inside the OnShow event of the
designer to change the page the designer initially loads. Something like
the following...
ppDesigner1.Notebook.SelectNextPage(False);
ppDesigner1.Notebook.ActivePageIndex := 0;
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Unfortunately the designer is limited in the way you can customize it. You
may need to take control of the menu defined in the Data workspace and
customize the import and export options so they filter your Items table
every time they are selected. I believe that when the Designer.TabChange
event is called, you can get access to the current designer window and use
the Designer.Menu property to customize this menu.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com