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)
DataSet Result Count
mpk
Hi All,
My requirement is to find out if the count of rows returned by a dataSet is 0. I want to store this in a variable based on which I want to set the visibility of a data element. I am unable to figure out which in method (beforeOpen(), onFetch()) of the dataset I should write this script and how can I retrieve the count.
Please suggest.
Thanks,
MK
Find more posts tagged with
Comments
Rajesh Kakawat
if you want to set Visibility of element if row count is 0,than you can set it by setting visibility property of element.You have to check hide Element and then
In That property you can write Expression like this :
if(Total.count()==0)
{
false
}
else
{
true
}
lazarel
You can also use the following bit code:<br />
<br />
<em class='bbc'>beforeOpen</em><br />
<pre class='_prettyXprint _lang-auto _linenums:0'>countId = new java.lang.Integer("0");</pre>
<em class='bbc'>onFetch</em><br />
<pre class='_prettyXprint _lang-auto _linenums:0'>countId++;</pre>
<em class='bbc'>beforeClose</em><br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.setPersistentGlobalVariable("countId",countId.toString());</pre>
Finally, to get value of countId in your report<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.getPersistentGlobalVariable("countId"));</pre>
<br />
Good Luck ^_^
mpk
Thanks for the replies
. I implemented it using scripting but in a different way.
In the header of the table to which the said dataset is bound, I declared a variable count (hidden) and initialized it to 0. In the detail row, I increment the variable. So, for each row its value is incremented by 1 and I have the result in the variable.
I inspect the variable value to find out if it is 0 which will be the case when the dataset returns 0 rows.