根据从下拉列表 属性 控件中选择的值更改多个默认过滤器:Spotfire
Change multiple default filters based on the value chosen from a dropdown property control: Spotfire
如何根据从下拉列表 属性 控件中选择的值更改多个默认过滤器?
如何实现此功能?
感谢任何帮助。
你的问题没有太多细节,所以我在这里做了很多假设,最重要的是 你正在处理 ListBox 过滤器;此代码不适用于其他过滤器类型。这是我正在使用的数据集:
NAME DEPARTMENT
alice marketing
bob sales
charley sales
dave engineering
- 在分析中,添加一个Text Area并插入一个Dropdown 属性 Control
- 单击 新建... 创建一个名为
Department
的新 文档 属性,它将是一个 String 并包含默认值 sales
- 通过以下方式设置 属性 值:列中的唯一值,然后选择
Department
列
- 单击脚本...,然后在对话框中选择执行下面select编写的脚本,然后点击新...
- 给脚本起一个像
ChangeFilter
这样的名字。 添加...一个脚本参数
- 调用脚本参数
department_name
,将其设置为String,然后select 属性:,最后点击Select 属性...设置为我们的department
文件属性
- 粘贴以下代码片段:
# import the ListBoxFilter class
from Spotfire.Dxp.Application.Filters import ListBoxFilter
# locate the data table and grab the filter collection
dt = Document.Data.Tables["Data Table"]
filters = Document.FilteringSchemes.DefaultFilteringSchemeReference[dt]
# repeat the below lines for any other filters you would like to change
# choose the filter we are interested in
f = filters["department"].As[ListBoxFilter]()
# unset "IncludeAllValues" or nothing we change will matter
f.IncludeAllValues = False
# set the value we are interested in
f.SetSelection(department_name)
- 接受所有对话,直到您返回分析并进行测试。
如何根据从下拉列表 属性 控件中选择的值更改多个默认过滤器?
如何实现此功能?
感谢任何帮助。
你的问题没有太多细节,所以我在这里做了很多假设,最重要的是 你正在处理 ListBox 过滤器;此代码不适用于其他过滤器类型。这是我正在使用的数据集:
NAME DEPARTMENT alice marketing bob sales charley sales dave engineering
- 在分析中,添加一个Text Area并插入一个Dropdown 属性 Control
- 单击 新建... 创建一个名为
Department
的新 文档 属性,它将是一个 String 并包含默认值sales
- 通过以下方式设置 属性 值:列中的唯一值,然后选择
Department
列 - 单击脚本...,然后在对话框中选择执行下面select编写的脚本,然后点击新...
- 给脚本起一个像
ChangeFilter
这样的名字。 添加...一个脚本参数 - 调用脚本参数
department_name
,将其设置为String,然后select 属性:,最后点击Select 属性...设置为我们的department
文件属性 - 粘贴以下代码片段:
# import the ListBoxFilter class from Spotfire.Dxp.Application.Filters import ListBoxFilter # locate the data table and grab the filter collection dt = Document.Data.Tables["Data Table"] filters = Document.FilteringSchemes.DefaultFilteringSchemeReference[dt] # repeat the below lines for any other filters you would like to change # choose the filter we are interested in f = filters["department"].As[ListBoxFilter]() # unset "IncludeAllValues" or nothing we change will matter f.IncludeAllValues = False # set the value we are interested in f.SetSelection(department_name)
- 接受所有对话,直到您返回分析并进行测试。