使用另一个 属性 控件更新 属性 控件值:Spotfire

Update property control value using another property control: Spotfire

我正在尝试实现一种功能,我想使用另一个 属性 控件更新 属性 控件的值。 下面是示例,我有一个名为 AsOfDate 的下拉列表 属性 控件,其中包含日期信息。使用在下拉列表中选择的值,我想以下拉列表或列表框的形式在下拉列表旁边显示相关的季度信息(此字段稍后将用作我的报告的列 header ).

这是我的方法:

  1. 创建了下拉列表 属性 控件。
  2. 使用下拉列表中的值,创建了一个计算列 季度信息。
  3. 在另一个 属性 中使用了计算列(第 2 步)中的值 控制。

问题:

第 3 步的值正在正确计算,但除非有用户输入,否则不会更新。如何根据仅选择 AsofDate(w/o 任何进一步的用户输入)来更新 属性 控件的值。

计算列代码:

case  
when Quarter(DocumentProperty("AsofDate")) IN (1) then 
Concatenate(Quarter(DocumentProperty("AsofDate")),Year(DocumentProperty("AsofDate"))) 
when Quarter(DocumentProperty("AsofDate")) IN (2, 3, 4) then 
Concatenate(Quarter(DocumentProperty("AsofDate")),Year(DocumentProperty("AsofDate")))
end

在随附的屏幕截图中,您可以看到,当我们展开第二个下拉列表时,季度信息就在那里,但除非用户选择,否则不会显示。

认为 您需要添加一个脚本,该脚本在 属性 控件更改并刷新那些 drop-down 框所在的文本区域时运行.

下面是执行此操作的示例 python 脚本(带有页面参数。如果不会太减慢脚本速度,您可以刷新所有页面上的所有文本区域):

from Spotfire.Dxp.Application.Visuals import Visualization, 
VisualTypeIdentifiers, HtmlTextArea

#Iterate through the page visualisations
for viz in page.Visuals:
        if viz.TypeId == VisualTypeIdentifiers.HtmlTextArea:
            viz.As[HtmlTextArea]().HtmlContent += " ";
        else:
            pass

假设您的两个下拉控件链接到一对名为 AB 的文档属性。 A 的可能值为 1-4。 B 的可能值基于计算列 [col] 中的唯一值,它是一些字符串和 A.

的值的串联

当我最初将 A 的值设置为 1 时,[col] 现在将包含 "Something1"、"SomethingElse1"、"SomeThirdThing1" 等值。附加到 B 的下拉列表现在包含这三个值,我 select "Something1",从而将 B 的值设置为 "Something1"。

接下来,我将 A 的值更改为 3。[col] 更新为包含 "Something3",等等。附加到 B 的下拉菜单现在显示“-- -".

出现这种情况的原因是因为文档属性B没有更新;它仍然设置为 "Something1",即使其附加的 属性 控件 可接受值 现在是 "Something3"等

Spotfire 中没有机制来解决这个问题;它需要一些脚本。

假设我在此处提出的示例,添加以下脚本以在 A 的值更改时随时执行。它总是将 B 的值更新为 [col].

列中的第一个结果
# import the DataValueCursor class
from Spotfire.Dxp.Data import DataValueCursor

# set up the data table reference
dt = Document.Data.Tables["Data Table"]
# set up the column reference
col = DataValueCursor.CreateFormatted(dt.Columns["col"])

# move the cursor to the first row of the column
# (GetRows() returns an iterable, and next() advances it to the first result)
dt.GetRows(col).next()

# update the document property
Document.Properties["B"] = col.CurrentValue

综上所述,虽然这是一个有趣的案例,但我想知道您正在尝试做什么以及是否没有更好的方法。此解决方案适用于您提出的问题,但我很想知道您的最终目标是什么,以及是否有更合适的解决方案来解决该问题。