How To Create A Report Template With 2 Level Sub Report

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:

  1. Create the Main Report Template (Orders.rml): create a Tabular Report and import all fields from the datasource into the main report.
  2. 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.
  3. 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.
  4. 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.
  5. 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. (10.3 KB)