2014-02-07 23 views
2

我想打印特定於儀表板每個頁面的過濾方案的「名稱」。需要IronPython代碼才能在Spotfire中輸出過濾方案

例如,儀表板的第1頁可能有一個名爲「過濾方案1」的過濾方案,第2頁有「過濾方案2」。我有代碼輸出所有的過濾方案,但我無法弄清楚如何將特定的方案關聯到它所在的頁面。

for pg in Document.Pages: 
    print pg.Title    # the page name 
    myPanel = pg.FilterPanel 
    print myPanel.Title   # output is the word: Filters 
    # THIS IS WHERE I WOULD WANT THE FILTERING SCHEME NAME TO APPEAR 
    print myPanel.Visible   # output: True 
    print myPanel.Context   # output: Spotfire.Dxp.Application.Filters.FilterPanel 
    print myPanel.TypeId   # TypeIdentifier:Spotfire.FilterPanel 
    print myPanel.FilteringSchemeReference 
    for i in range(myPanel.TableGroups.Count): 
    for gcObj in myPanel.TableGroups[i].FilterCollectionReference: 
     myFilter= myPanel.TableGroups[i].GetFilter(gcObj.Name) 
     if myFilter.Visible: 
     szCanSee = ' <Visible>' 
     else: 
     szCanSee = ' <Hidden>' 
     print myFilter.FilterReference.ToString() + szCanSee 
+0

+1寫得很好的第一個問題。 – RyanfaeScotland

+0

如果我的回答沒有回答你的問題,你可以回覆更多的細節,否則請考慮標記爲已接受。 – RyanfaeScotland

回答

1

您正在尋找DataFilteringSelection類,你可以在這裏API發現:http://stn.spotfire.com/dxp/html/AllMembers_T_Spotfire_Dxp_Data_DataFilteringSelection.htm

我已經下調把你的代碼段問起,你可能需要修改其餘部分因爲'myPanel'將不再是FilterPanel。

for pg in Document.Pages: 
    print pg.Title    # the page name 
    myPanel = pg.ActiveFilteringSelectionReference 
    print myPanel.Name   # output is the filter name 

爲了測試這個,我創建了一個4頁的文件:引言,解決方案1,解決方案2和頁面;和2個過濾器:過濾方案(1)和過濾方案(2)。除了使用過濾方案(2)的方案2以外,所有使用的都是過濾方案(1)。

這裏是我的輸出:

>  Introduction 
>  Filtering scheme (1) 
>  Solution 1 
>  Filtering scheme (1) 
>  Solution 2 
>  Filtering scheme (2) 
>  Page 
>  Filtering scheme (1)