How to get or set a specific filter using IronPython script in TIBCO Spotfire®
Last updated:
1:37pm Oct 01, 2018
 
Back to main page

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

Feedback (1)

Thanks for your response.

Actually my requirement is to uncheck the given IDs from the listboxfilter.

babu.saidu 9:32am Apr. 20, 2018