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)
Call Javascript of parent element
ksanta
Hi all,
Does anyone know of a way to call the Javascript of a parent element?
For example, say we have a data field in a common library with some Javascript in the onCreate() method. Next, say we drag in the data field to a report design and override the Javascript in the onCreate() method. By default, the Javascript in the parent will not get executed. Is there a way to do this?
Thanks,
Karl
Find more posts tagged with
Comments
mwilliams
Hi Karl,
I'm not sure I'm quite understanding. Could you explain your issue in a little more detail? Thanks!
ksanta
Hi Michael,<br />
Say we have a data element in a shared common library which looks something like this. The main purpose of this data element is to highlight the field red, and print an error message if a field is blank.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><data name="GenericData" id="6">
<method name="onCreate"><![CDATA[if(this.getValue() == "" || this.getValue() == null) {
this.getStyle().color = "Red";
var name = this.getName();
if (name) {
name = name.toUpperCase();
} else {
name = "DATA";
}
this.setDisplayValue("MISSING " + name);
}
]]></method>
</data></pre>
<br />
In the report design itself we have data elements which extend the one above. We would like to add additional functionality to these as well. For example we could map certain currency codes to new values in one common location:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><data name="CurrencyField" id="6091" extends="Custom.GenericData">
<method name="onCreate"><![CDATA[if(this.getValue() == "A") {
this.setDisplayValue("B");
}
]]></method>
</data></pre>
<br />
OK changing "A" to "B" is a made up example, but you get the idea. Notice how the second data element "extends" the first.<br />
<br />
When we run this, we expect the CurrencyField element to perform the mapping, but also to show up red and display an error message when the data is blank. But it doesn't.<br />
<br />
Is there a way the second element (the "child" element) can have it's own Javascript and still run the Javascript of the parent it extends?<br />
<br />
Thanks,<br />
Karl