2016-08-16 15 views
2

複数の選択リストボックスフィルタ(検索オプション付き)を作成するために鉄のpythonスクリプトを提供してください。スクリプトが埋め込まれたボタンをクリックすると、ダッシュボードページにある4つのデータテーブルのすべてに対してデータがフィルタリングされます。spotfireでフィルタを作成するための鉄のpythonスクリプト

私はいくつかのスクリプトを書いていますが、データテーブルが1つしかない場合は動作しています。複数のデータテーブルのデータにフィルタを適用しようとするとエラーが発生します。

from Spotfire.Dxp.Applica‌​tion 
import Filters as filters 

CurPanel = Document.ActivePageR‌​eference.FilterPanel 
FilterA = CurPanel.TableGroups‌​[0].GetFilter("column‌​name") 
CheckBoxes = FilterA.FilterRefere‌​nce.As[filters.CheckB‌​oxFilter]() 
strCityL = Document.Properties[‌​"propertyname"] 
    for CheckBoxVal in CheckBoxes.Values: 
     CheckBoxes.Uncheck(C‌​heckBoxVal) 
    for strVal in strCityL: 
     CheckBoxes.Check(st‌​rVal) 

上記のスクリプトは、1つのデータテーブルのためであり、私は私のフィルタがあなたを取得する必要

おかげ

+0

フィルタ CurPanel = Document.ActivePageReference.FilterPanel ます。FilterA = CurPanel.TableGroups [0] .GetFilter( "ColumnNameに") チェックボックスとしてSpotfire.Dxp.Applicationインポートフィルタからあなたがこれまで持っているスクリプト:) – scsimon

+0

を入力してくださいCheckBoxes.ValuesでCheckBoxValため= FilterA.FilterReference.As [filters.CheckBoxFilter]() strCityL = Document.Properties [ "プロパティ名"] :strCityLでstrValためCheckBoxes.Uncheck(CheckBoxVal) : \t CheckBoxes.Check( strVal) 上記のスクリプトは1つのデータテーブル用であり、フィルタ値を検索できません。 –

+0

私は偉大なarの鉄ではありません。ここに良いリンクがあります。 http://spotfired.blogspot.com/2014/03/change-filters-programatically-from.html 彼のプロフィールはこちらですhttp://stackoverflow.com/users/922290/jleviaguirre @jleviaguirre – scsimon

答えて

3

次のコード値検索することはできません。私は文書化したので、各行にいくつかのコンテキストを持たせて、必要に応じて他のフィルタにもこれを再現することができます。実際に、私はこのことから、実際には非常に違うだけで、他のフィルタがRangeFilterだと思うが、それはどこか別のポストだ:)

""" 
update the specified ListBox filter selection based on a parameter 

Parameters to be created: 
table -- the string name of the data table that will be filtered 
column -- the string name of the column to filter 
      IMPORTANT: set this filter type to ListBox using the Filters panel 
values -- a CSV string of the values to be selected 
""" 

# get the data table reference 
dt = Document.Data.Tables[table] 
# format our values into a list 
vals = values.split(',') 

# for debugging; safe to remove 
print("values:") 
print(vals) 

# import the necessary Spotfire classes 
from Spotfire.Dxp.Application.Filters import ListBoxFilter, FilterPanel 

# using the default Filtering Scheme and the supplied Data Table name, get the filter by its Column name 
filter = Document.FilteringSchemes.DefaultFilteringSchemeReference[dt][column] 
# cast it as a ListBox filter 
lb = filter.As[ListBoxFilter]() 

# reset the filter to its default state 
lb.Reset() 
# set the values according to the script parameter 
lb.SetSelection(vals) 
# OPTIONAL: select (true) or deselect (false) the "(All)" option 
lb.IncludeAllValues = False 
# OPTIONAL: select (true) or deselect (false) the "(Empty values)" option 
lb.IncludeEmpty = False 

# for debugging: safe to remove 
print("filter selection:") 
print(filter) 

する唯一の方法は実際にありますながらにフィルタを設定し、数がありますフィルタリファレンスを取得する方法について説明します。このコード(行番号23)は、私が発見した限りでは、フィルタを選択するためのコードを読むのが最も簡単で簡単です。あなたの分析と必要条件によってあなたの走行距離が変わることがあります。

+1

私はドキュメンテーションのために2回招待できました! – scsimon

関連する問題