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)
Hide Label and Image from Dataset fetch script.
JaiG
Hi,
I need help in hiding a Label and Image from Dataset fetch script.
I tried below codes:
reportContext.getDesignHandle().getElementByID(123).style.display = "none"; OR
reportContext.getDesignHandle().getElementByID(123).getStyle().display = "none"; OR
reportContext.getDesignHandle().getElementByID(123).display = "none"; OR
reportContext.getDesignHandle().getElementByID(123).setProperty('display', 'none');
Above 3 didn't work but I do see setProperty actually works, it changes the 'display' to 'none' but it doesn't reflect on UI, i.e. it still shows the Label :unsure:
I am using Excel Emitter as well to show report in Excel format.
Thanks in advance.
Jai Gharge
Find more posts tagged with
Comments
JaiG
I am still trying with this issue, not able to fix :unsure:
Now I added a new attribute to my dataset row["companyLogo"]
and I set this variable as row["companyLogo"] = true; from my dataset fetch script.
In the Image Visibility property I added a Expression in "For All Outputs" as :
row["companyLogo"] == true
So if from fetch script the value is set as true then this image will be invisible.
But this also is not working.
Please help.
Jai G
JaiG
Someone please HELP, I am stuck :unsure:
JaiG
Still not getting <_<
kclark
Do you have the image and label in a grid with each other? The easiest way would be to put them in a grid then drop the grid based on whatever logic you are trying to use.<br />
<br />
You can't do this from the onFetch() of the dataset. If you've set row["companyLogo"] to true you could do something like this from the beforeFactory() of the report<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if(row["companyLogo"] == "true") {
var grid = reportContext.getDesignHandle().getElementByID("102");
grid.drop();
} else {
// Do something else?
}</pre>
JaiG
Thanks for reply kclark.
Actually in my DataSet OPEN script I am setting the value of row["companyLogo"] as true or false, beforeFactory() gets executed after OPEN or before?
Also I have a Grid but in one cell itself I have a Label and Image.
From my application if user selects show company logo then i want to show the Image, and if user selects show company text then i want to show the Label.
I am getting the user input in DataSet OPEN.
Any other way I can achieve this?
kclark
You can click on the image and from the visibility tab in the property editor you can choose to hide the element.<br />
<br />
Then click the expression builder and make an expression to hide each doing something like this<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if(row["companyLogo"] == "false") {
false;
}else{
true;
}</pre>
<br />
And do the same for the label. Let me know if this works for you.
JaiG
Hi,
I already tried that, and now tried that again, it didn't work.
My report is generated in Excel using Tribix emittor.
I have attached my rptdesign file as well, please tell me if I am missing something.
Its been more than a week I am not able to fix this issue.
Thanks in advance,
Jai G
JaiG
Please help this is not yet fixed, I have also attached the rpt file in earlier post.
Jai G
kclark
I don't see the rptdesign attached, can you repost it?
JaiG
Hi kclark,
Please find the attached rptdesign file.
Thanks,
JaiG
kclark
You can't drop/hide from the fetch() because the rest of the report hasn't been created yet. I've attached an example of one way to do this similar to what I had said above.<br />
<br />
First I look for some value in the fetch() and then assign a pgv.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var myVar = row["CUSTOMERNUMBER"];
if (myVar == 103) {
reportContext.setPersistentGlobalVariable("test", "hideImage");
}</pre>
<br />
Then I had to add something from the dataset to the report above the image and make it invisible so this would trigger the script above to run.<br />
<br />
Then I was able to hide the image in the expression builder in visibility with this<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var myVar = reportContext.getPersistentGlobalVariable("test");
if(myVar == "hideImage") {
true;
}else{
false;
}</pre>
JaiG
Hi kclark,
I think this will not work.
I checked the flow and saw that expression in Visibility executes first then OPEN and FETCH script executes. (VISIBILITY EXPRESSION > OPEN SCRIPT > FETCH SCRIPT is the flow.)
So the values that are set in FETCH script is not used in Visibility expression.
Your variable myVar is null when expression in Visibility executes.
Please check again.
Also find attached my updated rptdesign file.
Thanks,
JaiG
kclark
I've updated your example, can you run this and tell me if it works? It looks like it's null because the dataset needs to be executed before the image viability script. So I inserted an invisible table above the main content.
JaiG
Hi,
Thanks a lot. It works exactly as expected.
But I am still not able to understand how invisible table helped to achieve this?
And now how script executes before Visibility expression?
Please elaborate. I might need to do it in other reports as well.
Thanks again,
Jai G
kclark
It's because the image you are wanting to hide/show is above the table that's linked to that data set. Without the hidden table it will create the image > create the data set for the table > create the table. So the script that hides the image is looking for a variable that doesn't yet exist. By adding the hidden table above the image this makes sure that your script in fetch() runs before the image is created.