Exclude Report Sections from being rendered using RenderIf scripting

This entry guides you through the steps on how to exclude report section from being rendered if it has no row of data or empty datasource by using RenderIf scripting

Scenario

  • Exclude report section 2 from being rendered since it has no row of data. Below was the initial report

image

image

RML template design as per below
Section 1
image
Section 2
image

  1. Under Report tab – Sections – Right click Section 2 – Edit Section

  1. In Section Wizard, click on Scripts tab and input below script inside RenderIf field
    var ds = DataCacheManager.getCache(“Fruit Sales 2”);
    ds.getRecordCount()!=0

  1. Click Finish and with above script, Section 2 will not be rendered.