Sub-Report
The Sub-Report element allows you to add a report into the current report. It is seen that one-to-many relationships are displayed by sub-reports where the main report usually displays one side of the relationship while the sub-report displays the many side of the relationship. There can be a single main report on which multiple sub-reports can be displayed. The same sub-report can be shared and used across any number of main reports.
Add Sub-Report
To add a sub-report in the report, select the “Sub-Report” button and click on the location where the sub-report is to be placed. A “SubReport Wizard” will appear.
The wizard consists of two tabs:
- SubReport - Allows you to define the sub-report
- Scripts - Allows you to add Java scripts for “Render If”, “On Render Begin” and “On Render End”
In the “SubReport” tab, either key in the path to the report or click on the button to select the desired report from the repository for the “Report” field. Select the desired section for the sub-report to render in from the drop-down list for the “Section” field. By default “Section 1” is selected. In the “Data Source” field, select the desired datasource from the drop-down list or click on the
button to select a datasource from the repository. This field can be left blank to indicate the default datasource defined by the chosen section.
Sub-reports can be set to grow vertically to accommodate all details that need to be shown, but will not grow horizontally. Ensure the report is wide enough to show the full width of the sub-report layout.
When a sub-report section is shown within a master report, certain characteristics can be overridden. For example, if the master report has defined a style for fields, the sub-report will use it instead of its own. Similarly, if the sub-report section uses a datasource called ABC, then the master can define a new ANC that will overrider it. While rendering the sub-report, whenever any resources are required and they are identified by name, then the renderer will first check the master report for a value before checking the sub-report. This allows the same sub-report to be used in multiple e=contexts and take on the characteristics of the master report in each case.
One side-effect of such behaviour is that, if you have a aub-report which uses a page setup called (Default) and your master has a page setup also called “Default”, then the master page setup will overrider the one defined in the sub-report. In this case, it is adviable to check carefully that the datasource names, page setup names and style names in the sub-report are unique, otherise the sub-report when embedded will not look the same as the sub-report if rendered separately.
When a sub-report is used in a master report, the following elements in the sub-report are not supported:
- Page header
- Force new page
- Page break
- Page footer
The sub-report may include multiple columns, but the report engine can only embed multiple columns if the page setup is defined as Across Then Down. Down Then Across columns cannot be handled by the sub-report renderer.
Do note that if a sub-report and a table is placed in the master report layout and they access dat from the same datasource, then they are both considered as discrete component and hence the datasource is loaded each time.
Edit Sub-Report
To edit the Sub-Report element in the report template, double-click on the Sub-Report element to display the “Properties” dialog box.
The tabs in the dialog box is similar to the Sub-Report Wizard.