This recipe demonstrates how to create a report template with 2 Level Sub Report.
Major steps and things to watch out for include the following:
- Create the Main Report Template (Orders.rml): create a Tabular Report and import all fields from the datasource into the main report.
- Create the Composite Data Source (cmps-OrderDetails.ds): set up the parameter in the Filter element correctly, which will affect the data passing between the sub report and main report.
- Create the 2 Level Sub Report Template (OrdersDetails.rml): explicitly name the datasources in the sub report, which will avoid the override of datasources with the same name (e.g. “Default”) between the sub report and main report.
- Add JavaScript into 2 Level Sub Report to sum up the values: enter the javascript for different elements carefully, which will affect the sum-up calculation within the sub report.
- Add the 2 Level Sub Report into the Main Report: change the datasource parameter value, which will have an impact upon the link between the sub report and main report.
Important: The followings are not supported in a Sub Report (OrdersDetails.rml):
- Page Header
- Force New Page
- Page Break
- Page Footer
To download the necessary files for this recipe, refer to the attached ZIP file.
2LevelSubReport.zip (10.3 KB)