Jump to content

How can I fix the dropdown filter to a specific value instead of "---"


Shirly Soloman

Recommended Posts

I have created a dropdown filter using expressions and it has 3 filter options : - 30 Days , 6 Months , 12 Months.

Everytime I open my dashboard or change the page, the filter is changed to " --- ".

Please suggest a solution to fix the filter to 6 Months, every time I revisit the page or open my dashboard.

Link to comment
Share on other sites

Hello Shirly

The dropdown is a way to control a document property. If the document property changes in any way, it will reflect that in your dropdown. If the document property does not match any of the dropdown options, the dropdown will display as "---"

If you have multiple pages using the same document property or a script that changes the document property for something else, for example, you have one page with a dropdown with options 3,6,9 and another page you have a dropdown with options 1,6 and 12, you will see "---" on page 1 if page 2 has 1 or 12 selected.

If you save the analysis and publish on the library with the "6 months" value and uncheck the "Remember personalized view for each web client user" every time they revisit the page when you open the dashboard, the 6 month value should remain there.

image.png.6a2032cecb60add076768cff8a9e1a7e.png 

Alternatively, you could create a script to run as soon as the page is revisited without having to reload the analysis to reset the document property to a default value (e.g. 6 months)

Link to comment
Share on other sites

reset.thumb.gif.6b05e5b98e292a11e0cc503dca62f0dc.gif 

You 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:

image.png.7f9989ac5db05a19134958f6e3f3b3b7.pngSo 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 "---"

image.png.6612f9040f69b52accf9e38a6a11fbc9.pngNow, 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>

image.png.be1f157da5fe2d04902566182b4bc683.pngAnd 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>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...