Jump to content
  • How to get or set a specific filter using IronPython script in Spotfire®


    The following is an example IronPython script which can get or set filters within a given Filtering Scheme.

    Introduction

    The following is an example IronPython script which can get or set filters within a given Filtering Scheme.

    Example

    from Spotfire.Dxp.Application.Filters import *
    
    from Spotfire.Dxp.Application.Visuals import VisualContent
    from System import Guid
    
    #Get the active page and filterPanel
    page = Application.Document.ActivePageReference
    filterPanel = page.FilterPanel
    
    #Get reference for FilteringScheme used for your filter
    for fs in Document.FilteringSchemes:
        if fs.FilteringSelectionReference.Name == "Filtering scheme": 
            filterPanel.FilteringSchemeReference = fs
    
    #Let's find "Col_LBFilter" filter and read the selected Values
    #This example uses a listbox filter, you may use any.
    filterPanel.InteractiveSearchPattern = "Col_LBFilter"
    for filter in filterPanel.FiltersMatchingSearchPattern:
        if filter.FilterReference.Name == "Col_LBFilter":
            lbFilter = filter.FilterReference.As[ListBoxFilter]()
    	#This will print selected values in List box filter
            print lbFilter.SelectedValues
    	#To set list box filter, Make sure that the data type of the values match the column type. In this example, "1,", "2", "5" are the actual column values to be selected in the filter.
    	_array = ["1,", "2", "5"]
    	lbFilter.IncludeAllValues=False
    	lbFilter.SetSelection(_array)
     

     

    References

    API Reference: Spotfire Analyst

    API Reference: ListBoxFilter. SetSelection

     

     

    License:  TIBCO BSD-Style License

     

     

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...