from Spotfire.Dxp.Application.Filters import CheckBoxFilter
#get a reference to a filter as checkbox
#myDataTable is a Data Table script parameter poining to the table with a "Region" column filter displayed as a Checkbox.
filt=Document.FilteringSchemes[0].Item[myDataTable].Item[myDataTable.Columns.Item["Region"]].As[CheckBoxFilter]()
#myDataTable is a Data Table script parameter poining to the table with a "Region" column filter displayed as a Checkbox.
filt=Document.FilteringSchemes[0].Item[myDataTable].Item[myDataTable.Columns.Item["Region"]].As[CheckBoxFilter]()
#uncheck all
filt.IncludeEmpty = False #make sure to clear the empty values
for
value in filt.Values:
filt.Uncheck(value)
filt.Uncheck(value)
#check one
filt.Check("Asia")
Range Filter Example
from Spotfire.Dxp.Application.Filters import RangeFilter, ValueRange
#get a reference to a filter as range
filt=Document.FilteringSchemes[0].Item[myDataTable].Item[myDataTable.Columns.Item["b"]].As[RangeFilter]()
#shift 0.1 to low and high range filter limits
newLow = filt.ValueRange.Low + .01
newHigh = filt.ValueRange.High + .01
newRange = ValueRange(newLow,newHigh)
filt.ValueRange = newRange
Range Filter Example
from Spotfire.Dxp.Application.Filters import RangeFilter, ValueRange
#get a reference to a filter as range
filt=Document.FilteringSchemes[0].Item[myDataTable].Item[myDataTable.Columns.Item["b"]].As[RangeFilter]()
#shift 0.1 to low and high range filter limits
newLow = filt.ValueRange.Low + .01
newHigh = filt.ValueRange.High + .01
newRange = ValueRange(newLow,newHigh)
filt.ValueRange = newRange
Range Filter Example 2
#sets date filter to today's date
from Spotfire.Dxp.Application.Filters import RangeFilter, ValueRange
from System import DateTime
#get a reference to a filter as range
filt=Document.FilteringSchemes[0].Item[myDataTable].Item[myDataTable.Columns.Item["Date"]].As[RangeFilter]()
newLow = DateTime.Now
newHigh = filt.ValueRange.High
newRange = ValueRange(newLow,newHigh)
filt.ValueRange = newRange
Change all filters (from all pages) to ListBoxFilter
for aPage in Document.Pages:
aFilterPanel = aPage.FilterPanel
for aTableGroup in aFilterPanel.TableGroups:
for aFilterHandle in aTableGroup.FilterHandles:
aFilterHandle.FilterReference.TypeId = FilterTypeIdentifiers.ListBoxFilter
3 comments:
Error given by the first line
Hello Payal Kumar
What error are you referring to? Without much feedback, I can only guess that you are referring to line #4 -or second statement that ends like: ".As[CheckBoxFilter]()"-
If you want to make it work on your end, then change myDataTable to the table that contains the "Region" column. Try creating a Data Table Script parameter called myDataTable. If your table does not have a Region column, then use the proper name. Also, make sure that the filter you are trying to change programatically with this script is actually a CheckBoxFilter (right click on your filter from the filter panel and select the check boxes option)
Remember that this, an all other scripts in this blog are only snippets of code for guide and reference for experienced users. You will have to change it according to your needs.
Hi! What do I need to code if my filter scheme is called "Center"
This is only affecting the main Filtering Scheme
filt=Document.FilteringSchemes[0].Item[myDataTable].Item[myDataTable...
Thank you!!!
Post a Comment