Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Dynamically dropping a table and chart
kevinshih
Hi all,
I wish to drop a chart, table, or other items from a report based on the result of a dataset. Basically, if the dataset returns with no data, I don't want the other items in the report to run, since their data is based on the results of the original dataset.
I have a data object that is bound to the original dataset. The dataset script increments a counter for each record it finds, and stores that counter in a global variable. In the data object script, I get the global variable, check it's value, and then drop the chart and table if the value is null. Here is the script code in the onPrepare() method of the data object:
var localInterfaceCount = reportContext.getGlobalVariable("interfaceCount");
//if (Packages.java.lang.Float.parseFloat(localInterfaceCount) < 1) {
if (localInterfaceCount < 1) {
reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("bandwidthSummaryTable").drop();
reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("chartBandwidthInByInterface").drop();
// reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("listInterfaces").drop();
}
What I'm finding is inconsistent behavior. For example, I have to comment out the drop() command for the table called "listInterfaces" in order for it to drop out when it should. But this is counter-intuitive to the code.
Any suggestions on what I missed?
Find more posts tagged with
Comments
mwilliams
You're saying that the table does drop out when you comment the drop code out for it? Or does it just not show because there is no data for it?
If you're having issues with dropping them with no data, you could just hide them if they have no data. They wouldn't take up much processing time if there is no data, so hiding could be just as effective.
kevinshih
Yes, the table drops out when the code is commented out.
I can't just hide the table, because it still tries to pull the dataset, and when it does, an exception is thrown. What is happening is I am using the original recordset to build a dynamic string of record ids, that I then use to pull the second dataset to generate the charts and tables. If the first recordset has no data, the second recordset query blows up.
mwilliams
Can you recreate your scenario with the sample database and I'll see if I can come up with anything to help?