繁体   English   中英

Spotfire中的列表框过滤器的铁python脚本

[英]iron python script for List box filter in spotfire

我有一个如下的脚本-

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追溯(最近一次呼叫最近):文件“ Spotfire.Dxp.Application.ScriptSupport”,行不明,在ExecuteForDebugging文件“”行,第16行,AttributeError:'ListBoxFilter'对象没有属性'Values'

System.MissingMemberException:'ListBoxFilter'对象在存根 $ 619 ## 619(Closure,CallSite,Object,CodeContext)处没有属性'Values'在Microsoft.Scripting.Actions.MatchCaller.Call2 [T0,T1,TRet](Func4 target, CallSite网站,位于Microsoft.Scripting.Actions.CallSite1.UpdateAndExecute(Object [] args),位于Microsoft.Scripting.Actions.UpdateDelegates.Update2 [T,T0,T1,TRet](CallSite网站,T0 arg0, T1 arg1)$ 606 ## 606(Closure,Scope,LanguageContext)在Spotfire.Dxp.Application.ScriptSupport.IronPythonScriptEngine.ExecuteForDebugging(String scriptCode,Dictionary2 scope,Stream outputStream)

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

看起来并没有完全相同的方法,但是有几种方法可以实现。

首先,有一个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()

它首先显示“过滤器列”名称,然后显示字符串列表中的选定值。 您可以据此进行调整。

暂无
暂无

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

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