pythonfilterironpythonspotfire

Reference FilterScheme's Name in Spotfire


I'd like to know how to reference a single filter within a scheme by name so I can clear it. But all the demonstrations I've found use ActiveFilteringSelectionReference so I'm having trouble figuring out how to write this script to target filters that are not the active filter on the page.

Specifically I need to reset the filter on the column "Team" of the Table "Timesheets" for the filtering scheme "TeamFilter". Here is my start. Line five is an error because FilteringSchemes does not want to take a string, but I don't know how to give it the name of the filter I want to reference.

import Spotfire.Dxp.Application.Filters as filters
from Spotfire.Dxp.Data import *
from Spotfire.Dxp.Application.Filters import *

myScheme = Document.FilteringSchemes["TeamFilter"]
myTable = Document.Data.Tables["Timesheets"]

filt=Document.FilteringSchemes[myScheme][myTable][myTable.Columns["Team"]]

filt.Reset()

Solution

  • You can use this code:

    #Reset filters across all filter schemes
    from Spotfire.Dxp.Application.Filters import *
    
    #Get the active page and filterPanel
    page = Application.Document.ActivePageReference
    filterPanel = page.FilterPanel
    #Find Filter Scheme
    for scheme in Document.FilteringSchemes:  
      if scheme.FilteringSelectionReference.Name == 'Test':
        filterPanel.FilteringSchemeReference = scheme
        print(scheme.FilteringSelectionReference.Name)
    
    #Reset Filter for Specific
    filterPanel.InteractiveSearchPattern = "Country" 
    for filter in filterPanel.FiltersMatchingSearchPattern:
        if filter.FilterReference.Name == "Country":
            lbFilter = filter.FilterReference.As[ListBoxFilter]() 
        lbFilter.Reset()
    

    https://community.tibco.com/wiki/how-get-or-set-specific-filter-using-ironpython-script-tibco-spotfire https://community.tibco.com/questions/how-reset-filtering-scheme-script https://community.tibco.com/questions/how-can-i-use-iironpython-script-set-filtering-scheme-multiple-tabs