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)
Checkbox - 'checked' based on data
BIRTing
Hi All,<br />
<br />
I'm trying to create a report in which I need checkboxes in the output coloumn. The checkbox should be checked/uncheked based on data.<br />
<br />
I used the below code in fetch method.<br />
<br />
<span style='font-family: Courier New'><em class='bbc'>var checked;<br />
<br />
if(maximoDataSet.getString("ticketid")=="1183")<br />
{<br />
checked="checked";<br />
}<br />
else<br />
{<br />
checked="";<br />
}<br />
<br />
check = "<input name='checkGroup' value='chk1' type='checkbox' "+checked+" >";</em></span><br />
<br />
I used the variable 'check' inside a dynamic text. <br />
<br />
I tried scriptlogger to see if the variable changes value for ticketid-1183 and it shows the value changed for that ticketid. But, in the output, the value is unchecked for all data.<br />
<br />
Please provide your inputs on this and also suggest some other ways of implementing this fucntionality.<br />
<br />
Thanks & Regards,<br />
Sankar Ganesh
Find more posts tagged with
Comments
Hans_vd
Sorry,
I have removed the code I posted. It does not work.
Tubal
This inside an HTML text element (not a dynamic text element) seemed to work for me:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><form name="myForm">
<input type="checkbox" name="mycheckbox" <VALUE-OF>if( row["proc_scope"]){
"checked";
}else{
"";
}</VALUE-OF>>My Checkbox</input>
</form></pre>
<br />
I think the problem with your code is that your var 'check' goes away when your onFetch script closes. So when it builds your table, it's not available anymore.<br />
<br />
Your code may work if you declare check as a global variable.<br />
<br />
So you could try something along the lines of:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var checked;
if(maximoDataSet.getString("ticketid")=="1183")
{
checked="checked";
}
else
{
checked="";
}
reportContext.setGlobalVariable("check","<input name='checkGroup' value='chk1' type='checkbox' "+checked+" >");</pre>
<br />
And then in your HTML text element:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><form>
<VALUE-OF>reportContext.getGlobalVariable("check")</VALUE-OF>
</form></pre>
<br />
I have not tested this, but it should work in theory.
BIRTing
Hi Tubal,<br />
<br />
Thanks for your input.<br />
I used your below code and it worked.<br />
<br />
<form name="myForm"><input type="checkbox" name="mycheckbox" <VALUE-OF>if( row["proc_scope"]){"checked";}else{"";}</VALUE-OF>>My Checkbox</input></form><br />
<br />
When I tried the 'Global variable' as you mentioned, it is giving '<em class='bbc'><input name='checkGroup' value='chk1' type='checkbox' ></em>' in the output for all data instead of checkboxes.<br />
<br />
However the other code works fine and I'm using it in my report now.<br />
Thanks!<br />
<br />
Regards,<br />
Sankar
Hans_vd
Tubal,
The solution I provided - before I edited my earlier post - also used a variable in the onFetch method and in the Text item expression, but it made the checkbox checked/unchecked based on the value of the previous row.
So checking the row data in the Text item expression itself is the way to go.