Avoid building element when its visibility evaluates to false #1630
Replies: 1 comment 6 replies
-
At the very first glance, yes. But if you take a closer look, there are often cases when you need to execute the dataset to decide if you want to show the layout item or not, for example, to hide a table (including header and footer!) if there are no rows. Both use-cases depend on the implementation as it is now. What you should do instead: Filter the data! So you should use either a filter condition based on the parameter "host_template_sheet" in the layout item (eg the table) that is bound to the data set. Or - much better - you can use a bind variable based on the parameter "host_template_sheet" in your data set, e.g. in an SQL WHERE condition. That way you only select the data from the DB if you really need to show it. |
Beta Was this translation helpful? Give feedback.
-
I recently built an excel report that has different sheets, and through report parameters we let the user decide which sheets should be included in the final result. After noticing that the report generation always lasted the same amount of time no matter the parameters and doing some logging I found out that altough the visibility is set to false
and the table doesn't show up in the output, it is still generated by birt (all of the scripts are being executed).
Currently I solved the problem in this way:
But I wanted to ask if there's an easier way, like a setting that avoids the "building" of elements that have their visibility set to false. Cause I would argue that in the vast majority of cases, if one hides an element in the report it would also be preferred not to spend resources in its generation. For this case in particular, since we're talking about a few very large excel tables (one took up almost 20s with the query etc.), adding this code once per table is not a big deal, but in other very dynamic reports, knowing that in order to not waste resources I should add this code for every element where I set a visibility expression is definitley not ideal
Beta Was this translation helpful? Give feedback.
All reactions