如何使用 Iron 创建过滤方案 Python

How to create a filtering scheme using Iron Python

是否可以创建新的过滤方案并将其设置为仅使用 Iron Python 的页面?我之所以对此进行调查,是因为网络播放器目前不允许我们创建过滤方案。我希望通过执行将由文档 属性 更改触发的脚本来实现。过滤方案的名称将从 JavaScript api 我使用 SetDocumentProperty 方法传递。

下面的脚本添加了一个新的过滤方案,但我无法从 Spotfire Analyst 的过滤方案菜单中 select 它,它无处可见。我错过了什么?

from Spotfire.Dxp.Data import *
from Spotfire.Dxp.Application.Filters import *

Document.ActivePageReference.FilterPanel.Visible = True
# Add a new data filtering selection.
filterings = Document.Data.Filterings

filterings.Add("Test Filtering 1")

for f in filterings:
    print f.Name

在我从 Analyst 的过滤方案菜单中 运行 上面的脚本后,我看不到我新添加的过滤方案:

这里的问题是 "filterings" 是您创建的一个变量,而不是过滤器列表的别名 -- 您用现有过滤器中的数据填充它,但之后更新过滤器不会更新页面本身的过滤器。

将代码更改为:

from Spotfire.Dxp.Data import *
from Spotfire.Dxp.Application.Filters import *

Document.ActivePageReference.FilterPanel.Visible = True
# Add a new data filtering selection.
Document.Data.Filterings.Add("Test Filtering 1")
filterings = Document.Data.Filterings

for f in filterings:
    print f.Name