This recipe shows how to select style using JavaScript.
Steps taken:
- Create a report template (DynamicSwitchingOfStyle.rml) using the given datasource (FruitSales.ds).
- Define the following parameter in the “Report > Parameters” page:Name=Locale, Value=${Locale#choice(Arabic,French)#Arabic}
- Enter the following script into “Report Properties > Scripts > On Render Begin”:chosenStyle = “”;
if (Properties.getProperty(“Locale”) == “French”) {
chosenStyle = “Style 1”;
}
else if (Properties.getProperty(“Locale”) == “Arabic”) {
chosenStyle = “Style 2”;
}
println(“Chosen Style >>” + chosenStyle); - Define the following function in the “Functions > On Render Begin” page:setStyle(getStyle(chosenStyle));
To download the necessary files for this recipe, refer to the attached ZIP file.
DynamicSwitchingOfStyle.zip (3.9 KB)