test

Warning when upgrading to Spotfire 10

TIBCO has deprecated the JQueryUI Javascript library in the latest Spotfire 10.0 release

TIBCO Community pages show us how to use JQuery properly

Rename an Action Control Button with a Document Property value

In this example, we want an Action Control Button that will toggle some Boolean Document Property. The state of the Document Property will be shown as the label of our Button Action Control.

Since I did not find an easy way to rename an Action Control Property using the API, I had to come with a work around by using some javascript.

To rename the button with a Document Control Value, put a Label Property Control on a Text Area next to your Button Action Control. Make sure you have a Document Property called 'toggle' set to False

html:
<DIV id="myPropertystyle='display:block' >
 <SpotfireControl id="465a3...." />
</DIV>

<DIV id="myControl">
 <SpotfireControl id="c05eba...." />
</DIV>


note: you can hide the label by changing display:block to display:none


javascript (newer verisons)
//get the document property value 
myProperty=$("#myProperty").text()

//rename the button (you can change other properties too)
control = $("#myControl input")
control.val(myProperty)

javascript (older version):
//get the document property value 
myProperty=document.getElementById("myProperty").innerText

//rename the button (you can change other properties too)
control = document.getElementById("myControl").firstChild
control.value = myProperty
//control.style.width = "100px"
//control.style.backgroundColor = "red"
//control.style.color = "yellow"




To change the document property and then trigger the javascript, via iron python, then use this code on the Action Control button:

#toogle the Boolean Document Property
Document.Properties["toggle"] = not Document.Properties["toggle"]

#Trigger the javascript on the text area after clicking
from Spotfire.Dxp.Application.Visuals import HtmlTextArea
vis.As[HtmlTextArea]().HtmlContent += " "




8 comments:

Anonymous said...

Could you please let me know, how to get the output, I tried my best but did not get the desired result. Please help me, when I try to copy the Java Script my Label is disappeared. Another problem, I am getting an exception with Iron Python script. Here is the short detail: Microsoft.Scripting.Runtime.UnboundNameException: name 'vis' is not defined
at IronPython.Runtime.PythonContext.MissingName(SymbolId name)
at Microsoft.Scripting.Runtime.LanguageContext.LookupName(CodeContext context, SymbolId name)

Jose Leviaguirre said...

'vis' is a Script Parameter that points to your text area visualization

Anonymous said...

Thanks, Jose
I appreciate for your help

ACLAP said...

Can you help, I get an Iron Python error: Microsoft.Scripting.Runtime.UnboundNameException: name 'HtmlTextArea' is not defined
at IronPython.Runtime.PythonContext.MissingName(SymbolId name). Thanks in advance.

Jose Leviaguirre said...

you need to add from Spotfire.Dxp.Application.Visuals import TablePlot, HtmlTextArea at the beginning of the python script

Vojtěch Fidler said...

Is this still working in new version of Spotfire? I tried in 7.8 and no success.

Jose Leviaguirre said...

hi Vojtěch,

Thanks for your comment. Yes, seems that the design architecture changed on the back end. Try using jquery in your javascript to get the values of your elements:

change:
myProperty=document.getElementById("myProperty").innerText
to:
myProperty=$("#myProperty").text()

and :
control = document.getElementById("myControl").firstChild
control.value = myProperty
to:
control = $("#myControl input")
control.val(myProperty)

I updated the post

Vojtěch Fidler said...

Thanks Jose, you are maestro :-) .