Passing parameters to a report
Hi,
I need to pass some parameters to a report to use in the data query, e.g.
Current UserID and Current CompanyID...
We have created TUser and TSystem classes in our application to hold all the
necessary properties (descendant from TObject).
I would much prefer to expose them to RAP rather than having to manually
code a stringlist as use a function to retrieve each parameter.
I have had a look at how to expose Delphi components to RAP, but cannot work
out how to expose classes. I have got as far as adapting the
GetDelphiComponent function and adapting it to a GetDelphiObject function
and have found the GetObjectFromProgram function but do not know what to
pass as a TraValue.
Am I going about this the right way?
What should I be doing?
Regards,
Pete Colson
I need to pass some parameters to a report to use in the data query, e.g.
Current UserID and Current CompanyID...
We have created TUser and TSystem classes in our application to hold all the
necessary properties (descendant from TObject).
I would much prefer to expose them to RAP rather than having to manually
code a stringlist as use a function to retrieve each parameter.
I have had a look at how to expose Delphi components to RAP, but cannot work
out how to expose classes. I have got as far as adapting the
GetDelphiComponent function and adapting it to a GetDelphiObject function
and have found the GetObjectFromProgram function but do not know what to
pass as a TraValue.
Am I going about this the right way?
What should I be doing?
Regards,
Pete Colson
This discussion has been closed.
Comments
Below are some options for definng parameters. The issue with RAP is going
to be a timing issue. Most of the events in RAP occur after the report
engine has been initialized - the datasets have been opened. The
BeforeAutoSearchDialogCreate and OnGetAutoSearchValues are the exeptions.
These only fire when AutoSearchFields have been defined for the query.
Options:
1. Use the Report.AutoSearchFields[]
2. Use the Report.Parameters[] property. This is a new general purpose
property that was added for RB 7. There is a design-time parameters editor
that is accessable via the context menu for the TppReport component. Press
the right mouse button and select the Parameters Editor property. See the
RBuilder.hlp for more details on using the Report.Parameters property.
3. Define your own classes and then define RAP RTTI classes that describe
them to RAP. There is a RAP tutorial on how to do this. There are many
examples in the RB source code. Start with ppRTTI where RAP Object,
Persistent, and Component are defined.
--
Nard Moseley
Digital Metaphors
http://www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com