To Pass Calculated Value to a Document Property as soon as the calculated value changes (e.g. changing filtered data or without clicking buttons, using IronPython or using Action Controls) is by using a timer.
In this example a Calculated Value is extracted and pasted into an Input Property Control via javascript. The Javascript function then updates the Document Property from an Input Property Control .
In order to make this automatic and reflect its value as soon as the filtered data changes, is by using a timer.
There is a better approach that requires no scripting, but a simple R Data Function!
html
<pre>
1. Create a calculated value
and put it inside the calcVal
tag:"<SPAN id="calcVal"><SpotfireControl id="af9f.." /></SPAN>"
2.Create a (hidden) input property control
that updates <i>myPropertyControl:</i> "<span style="DISPLAY: auto" id="inputPropertyControl"><SpotfireControl id="d037f..." /></span>"
3. Optionally add a
label property control to make sure the value is transferred
Label Property Control <i>myPropertyControl</i>:"<SpotfireControl id="25954a..." />"
4. Optionally add a button to manually trigger the javascript that transferred to the "myPropertyControl" Document Property:
<span id="transferValueBtn">Transfer</span>
</pre>
javascript:
var oldValue=0
transferValue = function(){
//get value from calcVal spotfire Calculated Value Dyn Item
value=$("#calcVal").text().trim()
//update input when oldValue changes
if(value!=oldValue){
$("#inputPropertyControl input").val(value).blur();
}
oldValue=value
}
//test value manually
$("#transferValueBtn").button().bind('click',transferValue)
//if button works, then un-comment this line to automatically refresh
//setInterval(transferValue,333) //3 times per second
3 comments:
Yes. I tested it and it works.
This is working but...
Saving seems to hang if I try to save my dxp while on the page this is on. Exporting to PowerPoint also seems to hang on the page this is used on.
So...
I'm trying to get this to run automatically but not infinitely. I thought of initially setting my target Document Properties to some guid (since blank is a plausible intended value to update it to) and then using a while to run transferValue until the Document Property equals the calculated value. I created a label with the target Document Property and thought I'd compare that to the calculated value. I'm just not having any luck.
Any ideas?
Post a Comment