David Jones 5 Posted January 17, 2020 Share Posted January 17, 2020 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 More sharing options...
David Jones 5 Posted January 17, 2020 Author Share Posted January 17, 2020 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now