Data columns along with their respective Data type is pulled in from Streaming File. All the Columns with String Data type should be displayed as "List Box" with default number of Rows and Search tab as well. And all the columns with Date Datatype should be Range Filters. and so on.
Can someone hint me on how to do this. Your help is much appreciated!! Thanks.
I believe this will do what you need. You may collect the data types/desired filter types differently. This just goes through the default data table in Spotfire.
from Spotfire.Dxp.Application.Filters import ListBoxFilter, RangeFilter, FilterTypeIdentifiers
# first collect all of the data types in the table
filterTypes = {}
for col in Document.Data.Tables.DefaultTableReference.Columns:
#if the column is not numeric or datatype, assume is text
if col.DataType.IsNumeric or col.DataType.IsTime:
filterTypes[col.Name] = "range"
else:
filterTypes[col.Name] = "list"
#now change all of the filter types based on the data types
for scheme in Document.FilteringSchemes:
for filter in scheme.DefaultFilterCollection:
type = filterTypes[filter.Name]
if type == "list":
filter.TypeId = FilterTypeIdentifiers.ListBoxFilter
filter.As[ListBoxFilter]()
else:
filter.TypeId = FilterTypeIdentifiers.RangeFilter
filter.As[RangeFilter]()