假設我正確理解您的情況,這將是我的建議:
有一個帶有標籤爲'Append'的按鈕,一個輸入字段(多行)和一個Refresh/Continue按鈕的文本區域。
讓用戶過濾往下找一個試驗,標誌着選定評估,然後點擊追加按鈕,用類似以下的腳本:他們希望
from Spotfire.Dxp.Data import *
crossSource = Document.Data.Tables["TrialsAndAssessments"]
rowIndexSet=Document.ActiveMarkingSelectionReference.GetSelection(crossSource).AsIndexSet()
colCurs = DataValueCursor.CreateFormatted(crossSource.Columns["AssessmentID"])
x = Document.Properties["udPreSelectedAssessments"]
#x = ""
if rowIndexSet.IsEmpty != True:
for row in crossSource.GetRows(rowIndexSet, colCurs):
#print colCurs.CurrentValue
if x == "":
x += colCurs.CurrentValue
else:
x += ", " + colCurs.CurrentValue
Document.Properties["udPreSelectedAssessments"] = x
他們附加在所有的評估到這個列表(他們也可以手動編輯),用戶可以點擊刷新/繼續按鈕。然後,此按鈕可以更改udSelectedAssessments屬性,該屬性鏈接到設置爲自動更新而不緩存的信息鏈接,該鏈接將成爲通過您的AssessmentID本身列表解析的存儲過程。 (我建議具有預先財產主要是讓你可以帶或遞東西到數據庫之前加撇號等)
刷新/繼續按鈕:
strVals = Document.Properties["udPreSelectedAssessments"]
lst = ""
x = 0
y = 0
z = 0
for letter in strVals:
if y == 1:
if letter == " ":
lst = lst + strVals[x:z] + ", "
y = 0
elif letter == ",":
lst = lst + strVals[x:z] + ", "
y = 0
elif letter == "\n":
lst = lst + strVals[x:z] + ", "
y = 0
elif letter == "\r":
lst = lst + strVals[x:z] + ", "
y = 0
elif letter == "'":
lst = lst + strVals[x:z] + ", "
y = 0
elif letter == '"':
lst = lst + strVals[x:z] + ", "
y = 0
elif letter == '\t':
lst = lst + strVals[x:z] + ", "
y = 0
else:
if letter <> " " and letter <> "," and letter <> "\n" and letter <> "\r" and letter <> "'" and letter <> '"' and letter <> "\t":
#print letter
x = z
y = 1
z += 1
if y == 1:
lst = lst + strVals[x:z]
print lst
Document.Properties["udSelectedAssessments"] = lst
簡單的T-SQL例如:
declare @run varchar(max) = '
select * from DataTableName where AssessmentID in (' + @AssessmentList + ')'
execute (@run)
編輯:這是我用於大型數據集的方法,我不想將服務器上的內存緩存起來,或者讓用戶等待分析過程的過長時間打開。如果您不必擔心其中的任何一種,因爲數據集很小,或者您無論如何緩存整個事情,以便更容易地選擇正確的評估,那麼我建議進行以下調整。
追加這段代碼上面的刷新按鈕提供的代碼:
Upper([Assessment]) in (${udSelectedAssessments) or ${udSpecialCheck} = 1
感謝:
使用原始數據集,而是由下面的代碼限制了數據表達的可視化切爾西!我對Spotfire中的編程沒有信心,因此需要與同事一起嘗試解決方案。如有必要,會回來提問。 –