Darren
Darren

Reputation: 153

How to disable or enable the chart visibility in BIRT

I have a problem, I need to dynamically show the chart according to the user's selection with BIRT. Could anyone tell me how to do that with script? I have created the parameter for the selection.

Upvotes: 0

Views: 1694

Answers (1)

Dominique
Dominique

Reputation: 4342

The easiest way is to set the visibility property of the chart (or of a grid containing this chart) with an expression using a parameter. This example hides the grid of a crosstab if the value of "View" report parameter equals to "charts".

enter image description here However this is not the most efficient approach, because if we just turn off the visibility of a report element its datasets are still running silently.

Therefore the best way is to drop elements from beforeFactory script of the report. This sample report makes use of both ways: the crosstab is hidden using visibility property, and the two charts are dropped in beforeFactory. Here is this beforeFactory script:

var design=reportContext.getDesignHandle();

if (params["View"].value=="cross"){
    design.findElement("gridCharts").drop();
}

Please notice the key point is to name report elements we need to drop.

Upvotes: 2

Related Questions