Here is a sample script to programatically via IronPython set a value for a filter in Spotfire; if the value does not exist in the allowed filter values, set it to the maximum possible
import Spotfire.Dxp.Application.Filters as filters
import Spotfire.Dxp.Application.Filters.ListBoxFilter
from Spotfire.Dxp.Application.Filters import FilterTypeIdentifiers
#use following line if the filter is to be applied to the currently active page - CAUTION, as we might alter the filter for a different filtering scheme then!
myPanel = Document.ActivePageReference.FilterPanel
# alternatively use following line to se it for a specific page
#myPanel = myPage.FilterPanel
#where myPage is a script parameter that points to the page we want it to work on
myFilter = myPanel.TableGroups[0].GetFilter("FILTER_NAME")
lbFilter = myFilter.FilterReference.As[filters.ItemFilter]()
if VALUE in lbFilter.Values:
lbFilter.Value = VALUE
else:
lbFilter.Value = max(lbFilter.Values)
Hi Stefano, I need this code to be modified like if the value does not exist in the above filter, i need to set it to 'ALL' in the mentioned fiter.. Can you help me on this please?
ReplyDeleteHello,
DeleteI would touch this line:
lbFilter.Value = max(lbFilter.Values)
and set your desired value instead of max(lbFilter.Values). From the Spotfire API doc guide you can find what should be set for 'ALL'
Cheers
Hello, thanks for the reply..
Deletei don't see anything for this in api doc, but i have made use of document property --> fixed values and made first row as ALL. so once All option is selected in the drop down and it will trigger the below script.
if VALUE in lbFilter.Values:
lbFilter.Value = VALUE
else:
lbFilter.Reset()
Nice, thanks for sharing :)
Delete