Extract Calculated Value to a Document Property when filtered data changes

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




Previous
Next Post »