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:
//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 += " "




Previous
Next Post »