【问题标题】:iron python script for List box filter in spotfire用于spotfire中列表框过滤器的铁python脚本
【发布时间】:2016-09-21 04:17:32
【问题描述】:

我有一个像下面这样的脚本 -

from Spotfire.Dxp.Application import Filters as filters
import Spotfire.Dxp.Application.Filters.ListBoxFilter
from Spotfire.Dxp.Application.Filters import FilterTypeIdentifiers
from Spotfire.Dxp.Data import *
from Spotfire.Dxp.Application.Filters import *

CurPanel = Document.ActivePageReference.FilterPanel
FilterA = CurPanel.TableGroups[1].GetFilter("column_name1")
CheckBoxesA = FilterA.FilterReference.As[filters.ListBoxFilter]()
FilterB = CurPanel.TableGroups[0].GetFilter("column_name2")
CheckBoxesB = FilterB.FilterReference.As[filters.CheckBoxFilter]()
print "success1"
for CheckBoxVal in CheckBoxesB.Values: CheckBoxesB.Uncheck(CheckBoxVal)
   print "success2"
str = CheckBoxesA.ToString()
found, nodes = myTable.Columns ["column_name2"].Hierarchy.Levels.LeafLevel.TryGetNodes(int.MaxValue)
for node in nodes:
   if str.Contains("All"): CheckBoxesB.check(node.Value.ValidValue)
   if str.Contains(node.Value.ValidValue): CheckBoxesB.check(node.Value.ValidValue)

当我在第 10 行使用 CheckBoxFilter 时,这完全可以正常工作。但是对于超过 100 的值,spotfire 会自动考虑列表框过滤器, 我应该如下修改第 10 行 -

CheckBoxesB = FilterB.FilterReference.As[filters.ListBoxFilter]()

然后我收到以下错误消息 -

success1 Traceback(最近一次调用最后一次):文件 “Spotfire.Dxp.Application.ScriptSupport”,行未知,在 ExecuteForDebugging 文件“”,第 16 行,在 AttributeError:“ListBoxFilter”对象没有属性“Values”

System.MissingMemberException:“ListBoxFilter”对象没有属性 “价值观” 在存根$619##619(闭包,调用站点,对象,代码上下文) 在 Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,Tret](Func4 目标,CallSite 站点,Object[] 参数) 在 Microsoft.Scripting.Actions.CallSite1.UpdateAndExecute(Object[] args) 在 Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,Tret](CallSite 站点,T0 arg0,T1 arg1) 在 $606##606(闭包,范围,LanguageContext) 在 Spotfire.Dxp.Application.ScriptSupport.IronPythonScriptEngine.ExecuteForDebugging(字符串 scriptCode、Dictionary2 范围、Stream outputStream)

我了解第 12 行和最后两行中使用的 uncheck 和 check 函数存在问题。列表框过滤器是否有任何等效功能?

【问题讨论】:

    标签: ironpython tibco spotfire


    【解决方案1】:

    看起来没有完全等价的,但有几种方法可以做到这一点。

    首先,有一个 IsSelected 方法,您可以在其中确定是否选择了 All,并相应地重置过滤器。

    if CheckBoxesB.IsSelected('All') ==  True:
      CheckBoxesA.Reset()
    

    如果需要,您可以使用字符串列表设置值,如下所示: http://spotfired.blogspot.com/2014/03/change-filters-programatically-from.html

    如果出于某种原因您确实需要获取从过滤器中选择的特定值,您可以通过添加以下代码来查看它们:

    CurPanel.InteractiveSearchPattern = "status:m"
    for filters in CurPanel.FiltersMatchingSearchPattern:
        ##Optional Table name to find column in specific table
        #if str(filters.ParentGroup) == "Table_Name":
        print filters.FilterReference.ToString()
    

    首先显示过滤器列名称,然后是字符串列表中的选定值。您可以进行相应的调整。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-03
      • 1970-01-01
      • 1970-01-01
      • 2013-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多