Modifying or Creating a Report at Runtime
|Product||Progress® Telerik® Reporting|
Our recommendation is to avoid making changes to the report definition. Note that it is always better to design reports with the available Report Designers and let the designer serialize the settings in a manner that will cause minimum issues on upgrade.
Flexibility in the layout can be achieved by showing/hiding items/sections via Conditional Formatting and Bindings, and Filtering data which results in not displaying certain parts of the report e.g. Using a dynamic filter to show/hide Crosstab/Table/List group members (columns).
Flexibility in retrieving data can be achieved by using parameterized data-retrieval methods. The method's arguments can be mapped to report parameters e.g. Using Parameters with the SqlDataSource component. You can also use a custom data access layer which fetches data in a manner fitting your requirements, where data objects can be consumed via ObjectDatasource/EntityDataSource or other component. For example, see Connecting Telerik Reporting to OData feeds.
In case the available designers and wizards do not help you to accomplish your task, the recommended approach to modify/create reports is before starting to process them (before displaying them).
To modify a report, you can create an instance of the report designed in the Visual Studio Report Designer, or you can deserialize/unpackage a TRDX/TRDP file to get a
Telerik.Reporting.Reportinstance for work. Once you have the report instance, you have access to all items in it through the report's
Itemscollection. You can use the Find method to get a specific item/section that has to be modified.
An example of such modification is illustrated in Changing the connection string dynamically according to runtime data.
To create a report, our recommendation is to start by using the Visual Studio Report Designer. You can create a sample report with the desired layout and test data. The VS Report Designer will serialize automatically the settings in the report's
Designer.cs|vbfile. This code can be re-used and modified at run-time.
All modifications must be done before wrapping the report in a Report Source object on the server machine. If you are using a Reporting RESTor WCF service, modifications can be done in a custom ReportSource resolver plugged in the service.
Events are not recommended for modifying/creating items and data source components as they fire once the report's processing is started, at that time, the report template is evaluated against the assigned data.