Product: TIBCO Spotfire®
How to get or set a specific filter using an IronPython script
The following is an example IronPython script which can get or set filters within a given Filtering Scheme.
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.SetSelection(_array)
Disclaimer:
The script code in this article is only a sample to be used as a reference. It is not intended to be used "As Is" in a Production environment. Always test in a Development environment. Make modifications to the script in accordance with your implementation specifications that best suit your business requirements. Refer to the API reference(s) cited in this article for usage of the classes and methods used in the script.
https://docs.tibco.com/pub/doc_remote/spotfire/6.0.0-november-2013/api/?topic=html/M_Spotfire_Dxp_Application_Filters_ListBoxFilter_SetSelection_1.htm
IronPython, Iron Python, Script, Filter, filtering scheme
Comments
0 comments
Article is closed for comments.