Suppose you have a dashboard and have an Drop-down list Input Property Control that holds 3 different custom expressions that limits the data on one of your visualizations, but you want to always start at a specific value every time the user revisits that page.
In this case we have a can add a reset button (Action Control) with the following IronPython script to reset to the default expression like this:
Document.Properties["DateRangeExpression"] = "[Date] >= dateadd('mm',-6,Max([Date]))"
This script assumes you have a Drop-down list Property Control linked to a document property called "dateRangeExpression" that holds 3 values:
30 Days [Date] >= dateadd('dd',-30,Max([Date])) 6 Months [Date] >= dateadd('mm',-6,Max([Date])) 12 Months [Date] >= dateadd('mm',-12,Max([Date]))
So the script will "reset" to the default value for the 6 month expression. Please note that the expression on the Script and on the drop-down list have be exactly the same. Otherwise you will get "---" in your dropdown
Now, if you want to have that button automatically clicked when you revisit the page, you will need a JavaScript to do so. You will first need to wrap the reset button with some html:
<span id=resetButton> <SpotfireControl id="1e84eda67d3c44c5b179f8419adc58be" /> ◄ reset button</span>
The final step is to add this JavaScript to automatically click the button when you revisit the page
document.querySelector("#resetButton input").click()
If you do not want to have the reset button visible, you can hide it by adding the hidden attribute on the wrapper of your button:
<span id="resetButton" hidden> <SpotfireControl id="1e84eda67d3c44c5b179f8419adc58be" /> </span>
Recommended Comments
There are no comments to display.