Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Drop Element From a Report Design Based on Computed Column
kpelzer29
How can I drop a table or grid containing a table based on a computed column value from a data set? The computed column will contain "Yes" if the table should appear in the report or "No" if the table should not appear in the report. I am unable to use the visibility property of the table because I do not want the report item to still be processed.<br />
<br />
I have tried using a persistent global variable to store the value of the computed column in the onFetch event script of the data set:<br />
<br />
<em class='bbc'>reportContext.setPersistentGlobalVariable("DisplayMeValue", row["Display_Me"];</em><br />
<br />
<br />
Then I named the table "table1" that may or not be displayed depending on the computed column value and put in the beforeRender Report event script the following code:<br />
<br />
<em class='bbc'>var DisplayMeSetValue;<br />
<br />
DisplayMeSetValue = reportContext.getPersistentGlobalVariable("DisplayMeValue");<br />
<br />
if (DisplayMeSetValue == "No")<br />
{<br />
reportContext.getDesignHandle.findElement("table1").drop();<br />
}<br />
</em><br />
<br />
For some reason in the beforeRender Report event the code does not seem to recognize the value I set for the persistent global variable from the onFetch event of the data set. Even when the computed column value = "No", the table still appears in the report. The variable DisplayMeSetValue is null. I added a text box to the report to display the value of the persistent global variable using <em class='bbc'> <VALUE-OF>reportContext.getPersistentGlobalVariable("DisplayMeValue")</VALUE-OF></em> to make sure a value is actually being assigned and it looks like it is being set in the onFetch event to the computed column value. I do not understand why it is not recognized in the beforeRender event for the Report. What should I do differently? Is there a better way to accomplish the same task? Thank you!
Find more posts tagged with
Comments
bgbaird
I would just set the visibility property based on the condition.
kpelzer29
Hi bgbird,<br />
<br />
Thank you for your response. The problem with setting the visibility property based on the condition is that even when the table is not visible, the user could still export the data from the report and see the data. We want to make it so that if someone is not allowed to see the data they will not be able to. Any suggestions?<br />
<br />
<blockquote class='ipsBlockquote' data-author="'bgbaird'" data-cid="109117" data-time="1346950159" data-date="06 September 2012 - 09:49 AM"><p>
I would just set the visibility property based on the condition.<br /></p></blockquote>
bgbaird
You could filter the dataset something like this:
if({condition}==true){true;}
else {false;}
Or you could do a scripted dataset to act as a buffer between the data and the presentation (the JVM might get pretty big)
Or you might have two datasets, the first just determines if you need to get the second.
kpelzer29
Thank you! How would I get it to work having the two datasets, the first determining if you need to get the second? <br />
<br />
We have a data set with the computed column in it to determine if the user should be able to see the table. We also have another data set bound to the table we want to drop if the user is not supposed to see the data. <br />
<br />
<blockquote class='ipsBlockquote' data-author="'bgbaird'" data-cid="109121" data-time="1346960205" data-date="06 September 2012 - 12:36 PM"><p>
You could filter the dataset something like this:<br />
<br />
if({condition}==true){true;}<br />
else {false;}<br />
<br />
Or you could do a scripted dataset to act as a buffer between the data and the presentation (the JVM might get pretty big)<br />
<br />
Or you might have two datasets, the first just determines if you need to get the second.<br /></p></blockquote>
wwilliams
Could you add a dataset to get your computed value? If so, then in the beforeFactory add code to selectively drop your dataset.
Add a variable in the initalize method
myVar="";
then in the fetch of the extra dataset
myVar == row["computed"];
if(myVar=="VALUE"){
reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("other").drop();
} else {
reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("me").drop();
}
kpelzer29
Hi wwilliams,<br />
<br />
Thank you for the reply. I tried what you suggested, but it doesn't seem to work for me. I even tried just putting this line in the onFetch of the dataset with the computed column (without the if statement)<br />
<br />
<em class='bbc'>reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("table1").drop();</em><br />
and table1 still appears in the report.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'wwilliams'" data-cid="109149" data-time="1347277478" data-date="10 September 2012 - 04:44 AM"><p>
Could you add a dataset to get your computed value? If so, then in the beforeFactory add code to selectively drop your dataset.<br />
Add a variable in the initalize method<br />
<br />
myVar="";<br />
<br />
then in the fetch of the extra dataset<br />
<br />
myVar == row["computed"];<br />
<br />
if(myVar=="VALUE"){<br />
reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("other").drop();<br />
} else {<br />
reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("me").drop();<br />
<br />
}<br /></p></blockquote>