Hiding Report Sections based on a Data Field value

This entry guides you through the steps on hiding of report sections using RenderIf scripting.


Scenario:

  • Hide Section 2 if Fruit equals to “Apple”.

Initial:


^ Section 1

^ Section 2

1/ RML template is configured as follows:

  • Section 1
    image

  • Section 2
    image

2/ Click on the “Report” tab, right-click Section 2 and click “Edit Section”.

3/ In Section Wizard, click on the “Scripts” tab and input in the following:

var ds = DataCacheManager.getCache("fruit1"); 
ds.getString("Fruit")=="Apple";

reference:


4/ Save the RML template.

Output:

If Fruit equals to “Apple”, Section 2 will be rendered.
image

If Fruit equals to “Orange”, Section 2 will not be rendered.
image

Sample RML template and datasource:
hide-report-section.zip (2.2 KB)