Spotfire IronPython: Reset all visible filters

Posted on Updated on

IronPython Code to reset all applied visible filters:

import Spotfire.Dxp.Application.Filters as filters
from Spotfire.Dxp.Application.Filters import *
# Navigate through each page in the analyses
for eachPage in Document.Pages:
# Get the active data table in the current page
activeTable = eachPage.ActiveDataTableReference
# Get the set of all table groups in the current page
tableGroup = eachPage.FilterPanel.TableGroups
# Navigate through all the table groups in the filter panel of current page
for t in tableGroup:
# To filter on the active data table used in the filter panel
if (t.Name == activeTable.Name):
# In table group (data table), navigate through the filter groups
for filterSubGroup in t.SubGroups:
# Navigate through the filters in each filter group
for filterHandle in filterSubGroup.FilterHandles:
filterReference = filterHandle.FilterReference
# Reset if the filter is visible
if filterHandle.Visible==True:
filterReference.Reset()
print "Reset done for: " + eachPage.Title + '.' + t.Name + '.' + filterSubGroup.Name + '.' + filterReference.Name
if filterHandle.Visible==False:
print "Reset not done for: " + eachPage.Title + '.' + t.Name + '.' + filterSubGroup.Name + '.' + filterReference.Name

Please take note that this script can be used to not reset the hidden filters in the analyses. That is, this will reset all the visible filters which are part of filter groups across all the pages in the analyses.

Snapshot for indentation reference:

Spotfire_IronPython_Reset_All_Visible_Filters

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s