簡體   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