This recipe demonstrates how to work on section handling using script.
Steps taken:
Create a report template (JP Manpower Distribution with Grouping.rml).
Create “Section 1” and “Section 2” in the report template with different coloring.
Enter the following script into each place:
(Section 1 > Section Header > On Render End:)
swap(Renderer.getRawReport());
(Section 1 > Group Header > department_id > Field Properties (Script)
"Department "+department_id
(Section 1 > Field (Department ID) > Field Properties (Script)
"Department "+ department_id
(Section 1 > Field (Department ID) > Field Properties (Script)
"Total for “+education_level+”: "
(Section 1 > Field (Department ID) > Field Properties (Script)
"Total for Department “+department_id+”: "
(Section 2 > Page Header > On Render End:)
swap(Renderer.getRawReport());
(Layout > Function Definitions:)
function swap(report)
{
var s1 = report.getSection(0);
var ph1 = s1.getPageHeader();
var s2 = report.getSection(1);
var ph2 = s2.getPageHeader();
s1.setPageHeader(ph2);
s2.setPageHeader(ph1);
}
To download the necessary files for this recipe, refer to the attached ZIP file.
SectionsHandling.zip (5.6 KB)