Jump to content
We've recently updated our Privacy Statement, available here. ×

How to reset all visible filters across all filtering schemes


David Jones 5

Recommended Posts

Exactly what the title says. I'm trying to create an ironpython script that will clear all filters across all filtering schemesthat are visible. It's important that this does not clear predefined filters. Currently I'm using :

 

from Spotfire.Dxp.Application.Filters import FilteringSchemeCollection

 

#Get a list of tables from the active page

tg = Document.ActivePageReference.FilterPanel.TableGroups

 

 

#Show available filters

print "Available filters:"

for t in tg:

print t

print "------------n"

 

#See if a filter is available on the filter panel

print "Visibility of filters in a table group"

for h in tg[0].FilterHandles:

print h.FilterReference.Name, h.Visible

print "------------n"

 

#Reset all available filters

print "Print all available filters and reset only the visible ones"

for t in tg:

for h in t.FilterHandles:

f = h.FilterReference

 

#print available filters (and visibility status)

print '[',t,'].[',f.Name,'].Visible = ',h.Visible

 

#reset the filter only if it's visible

if (h.Visible): f.Reset()which I got from here:https://spotfired.blogspot.com/2014/08/reset-visible-filters.html.

The problem I'm running into is this only clears one filtering scheme. I have several visualizations on each tab that interact with multiple filter schemes. Any help is appreciated!

 

Thanks

Link to comment
Share on other sites

Ok this works:

from Spotfire.Dxp.Application.Filters import FilteringSchemeCollection

from Spotfire.Dxp.Application.Filters import *

from Spotfire.Dxp.Application.Visuals import VisualContent

#select the filtering scheme

myFilteringScheme = Document.FilteringSchemes[0];

Document.ActivePageReference.FilterPanel.FilteringSchemeReference = myFilteringScheme;

 

#Get a list of tables from the active page

tg = Document.ActivePageReference.FilterPanel.TableGroups

 

myFilteringScheme = Document.FilteringSchemes[0];

Document.ActivePageReference.FilterPanel.FilteringSchemeReference = myFilteringScheme;

#Show available filters

print "Available filters:"

for t in tg:

print t

print "------------n"

 

#See if a filter is available on the filter panel

print "Visibility of filters in a table group"

for h in tg[0].FilterHandles:

print h.FilterReference.Name, h.Visible

print "------------n"

 

#Reset all available filters

print "Print all available filters and reset only the visible ones"

for t in tg:

for h in t.FilterHandles:

f = h.FilterReference

 

#print available filters (and visibility status)

print '[',t,'].[',f.Name,'].Visible = ',h.Visible

 

#reset the filter only if it's visible

if (h.Visible): f.Reset()

 

myFilteringScheme = Document.FilteringSchemes[1];

Document.ActivePageReference.FilterPanel.FilteringSchemeReference = myFilteringScheme;

#Show available filters

print "Available filters:"

for t in tg:

print t

print "------------n"

 

#See if a filter is available on the filter panel

print "Visibility of filters in a table group"

for h in tg[0].FilterHandles:

print h.FilterReference.Name, h.Visible

print "------------n"

 

#Reset all available filters

print "Print all available filters and reset only the visible ones"

for t in tg:

for h in t.FilterHandles:

f = h.FilterReference

 

#print available filters (and visibility status)

print '[',t,'].[',f.Name,'].Visible = ',h.Visible

 

#reset the filter only if it's visible

if (h.Visible): f.Reset()

 

myFilteringScheme = Document.FilteringSchemes[2];

Document.ActivePageReference.FilterPanel.FilteringSchemeReference = myFilteringScheme;

#Show available filters

print "Available filters:"

for t in tg:

print t

print "------------n"

 

#See if a filter is available on the filter panel

print "Visibility of filters in a table group"

for h in tg[0].FilterHandles:

print h.FilterReference.Name, h.Visible

print "------------n"

 

#Reset all available filters

print "Print all available filters and reset only the visible ones"

for t in tg:

for h in t.FilterHandles:

f = h.FilterReference

 

#print available filters (and visibility status)

print '[',t,'].[',f.Name,'].Visible = ',h.Visible

 

#reset the filter only if it's visible

if (h.Visible): f.Reset()It's probably not efficient, but at least it's working.

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...