Bha*_*hek 3 ironpython spotfire
可以请一个人提供python脚本来创建多个选择列表框过滤器(带有搜索选项)。当我单击嵌入脚本的按钮时,应该对仪表板页面中存在的所有四个数据表的数据进行过滤。
我已经编写了一些脚本,但是如果仅存在一个数据表,它将可以正常工作,当我尝试对多个数据表中的数据应用过滤器时,我遇到了一些错误。
from Spotfire.Dxp.Applica??tion
import Filters as filters
CurPanel = Document.ActivePageR??eference.FilterPanel
FilterA = CurPanel.TableGroups??[0].GetFilter("column??name")
CheckBoxes = FilterA.FilterRefere??nce.As[filters.CheckB??oxFilter]()
strCityL = Document.Properties[??"propertyname"]
for CheckBoxVal in CheckBoxes.Values:
CheckBoxes.Uncheck(C??heckBoxVal)
for strVal in strCityL:
CheckBoxes.Check(st??rVal)
Run Code Online (Sandbox Code Playgroud)
上面的脚本用于一个数据表,我无法搜索过滤器值
谢谢
小智 5
以下代码将带您到达那里。我已经记录在案,以便您可以为每行提供一些上下文,并希望为您需要的任何其他过滤器重现此上下文。实际上,我认为与此唯一非常不同的其他过滤器是RangeFilter,但这是某处的另一篇文章:)
"""
update the specified ListBox filter selection based on a parameter
Parameters to be created:
table -- the string name of the data table that will be filtered
column -- the string name of the column to filter
IMPORTANT: set this filter type to ListBox using the Filters panel
values -- a CSV string of the values to be selected
"""
# get the data table reference
dt = Document.Data.Tables[table]
# format our values into a list
vals = values.split(',')
# for debugging; safe to remove
print("values:")
print(vals)
# import the necessary Spotfire classes
from Spotfire.Dxp.Application.Filters import ListBoxFilter, FilterPanel
# using the default Filtering Scheme and the supplied Data Table name, get the filter by its Column name
filter = Document.FilteringSchemes.DefaultFilteringSchemeReference[dt][column]
# cast it as a ListBox filter
lb = filter.As[ListBoxFilter]()
# reset the filter to its default state
lb.Reset()
# set the values according to the script parameter
lb.SetSelection(vals)
# OPTIONAL: select (true) or deselect (false) the "(All)" option
lb.IncludeAllValues = False
# OPTIONAL: select (true) or deselect (false) the "(Empty values)" option
lb.IncludeEmpty = False
# for debugging: safe to remove
print("filter selection:")
print(filter)
Run Code Online (Sandbox Code Playgroud)
虽然实际上只有一种设置过滤器的方法,但是有很多方法可以获取过滤器参考。据我发现,这段代码(第23行)是最简单,最容易阅读的用于选择过滤器的代码。您的里程可能会因您的分析和要求而异。
| 归档时间: |
|
| 查看次数: |
2737 次 |
| 最近记录: |