简体   繁体   English

Spotfire Ironpython - 根据在下拉列表中选择另一个文档属性来更新文档属性

[英]Spotfire Ironpython - Update a document property based on selection of another document property in drop down list

I am trying to make a complex data condition where the filter should be applied only if a property value is set for the logic.我正在尝试创建一个复杂的数据条件,其中仅在为逻辑设置属性值时才应应用过滤器。

在此处输入图像描述

In the below screenshot, I am trying to set a condition where if the Business in dropdown is (None), then the Business Filter will be set to TRUE using Ironpython script.在下面的屏幕截图中,我试图设置一个条件,如果下拉列表中的业务为(无),则业务过滤器将使用 Ironpython 脚本设置为 TRUE。

在此处输入图像描述

The iron python script is below:铁蟒脚本如下:

from System.Collections.Generic import List
from Spotfire.Dxp.Data import *

If Document.Properties["Business"] == NULL:
    Return Document.Properties["BusinessFilter"] = TRUE
ELSE
    Return Document.Properties["BusinessFilter"] = FALSE

But the code isnt working.但是代码不起作用。 Your help is very much appreciated.非常感激你的帮助。

There are a few syntax issues, this worked for me (setting the script to be executed when the property 'Business' changes value)有一些语法问题,这对我有用(设置要在属性“业务”更改值时执行的脚本)

if Document.Properties["Business"] == None:
     Document.Properties["BusinessFilter"] = True
else:
     Document.Properties["BusinessFilter"] = False

if/else seem to have to be lowercase (you notice they are right when they turn blue in the editor); if/else 似乎必须是小写的(当它们在编辑器中变为蓝色时,您会发现它们是正确的); you need : after else, you don't need Return;你需要:否则,你不需要返回; and True and False need to be in Python format (so not TRUE but True) if you want a boolean property.如果您需要布尔属性,则 True 和 False 需要采用 Python 格式(所以不是 TRUE 而是 True)。 The code worked without the imports on top.该代码在没有顶部导入的情况下工作。

I was able to obtain the desired filtering logic using the below code easily.我能够使用下面的代码轻松获得所需的过滤逻辑。

Now I am able to filter data using "Business" filter when selected otherwise go for all data to be visible.现在,我可以在选择时使用“业务”过滤器过滤数据,否则所有数据都可见。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM