簡體   English   中英

有沒有辦法將用戶輸入附加到spotfire 中的表格?

[英]Is there a way to get user input appended to a table in spotfire?

我在 Spotfire (dcube) 中有一個表Table1 ,其中包含一些上下文信息,其中包含以下內容:

Name      Food    Seating
XYZ     Seafood   outdoors

我創建了一個帶有兩個按鈕YesNo的測試區域。 用戶將在Table1選擇一條記錄並單擊其中一個按鈕,它應該使用添加的列Preference填充另一個表Table2 ,輸出如下:

Name      Food    Seating   Preference
XYZ     Seafood   outdoor     Yes

根據用戶Yes單擊Yes還是No來填充preference列的值。 當用戶為Table1另一條記錄設置首選項時,它應該作為一行附加到Table2

在不使用 TERR 的情況下,這是否可以通過 R 或 IronPython 實現?

您可以使用 python 並寫回數據庫來實現這一點。 但是我不確定在沒有外部數據源的情況下有什么好的/有效的方法來做到這一點。

from Spotfire.Dxp.Data.Import import DatabaseDataSource
from Spotfire.Dxp.Data.Import import DatabaseDataSourceSettings
from Spotfire.Dxp.Application.Visuals import TablePlot
from Spotfire.Dxp.Application.Visuals import VisualTypeIdentifiers
from Spotfire.Dxp.Data import IndexSet
from Spotfire.Dxp.Data import RowSelection
from Spotfire.Dxp.Data import DataValueCursor
from Spotfire.Dxp.Data import DataSelection
from Spotfire.Dxp.Data import DataPropertyClass

rowCount = Document.ActiveDataTableReference.RowCount
rowsToInclude = IndexSet(rowCount,True)

#Get a cursor to the two columns we want to use. cursor1 is for the key column and cursor2 is for the column selected by the user input

cursor1 = DataValueCursor.Create[int](Document.ActiveDataTableReference.Columns["ProductID"])
cursor2 = DataValueCursor.CreateFormatted(Document.ActiveDataTableReference.Columns[whichCol])

#The following section will add a column to the database table using the name specified by the user. This assumes a column with this name does not already exist.

sqlCommand = "ALTER TABLE Products ADD " + colName + " varchar(50);"
dbsettings = DatabaseDataSourceSettings( "System.Data.SqlClient","Server=localhost;Database=myDB;UID=myuser;PWD=mypass",sqlCommand)
ds = DatabaseDataSource(dbsettings)
newDataTable = Document.Data.Tables.Add("temp",ds)
Document.Data.Tables.Remove(newDataTable)

#The following section will update the specified column in the database using the key column in the where clause
sqlStr=""
for  row in  Document.ActiveDataTableReference.GetRows(rowsToInclude,cursor1,cursor2):
   value1 = cursor1.CurrentValue
   value2 = cursor2.CurrentValue
   sqlStr = sqlStr +  "UPDATE Products SET " + colName + "='" + value2 + "' WHERE (ProductID=" + str(value1)  + ");"

sqlCommand = "UPDATE Products "  + sqlStr + ";"
dbsettings = DatabaseDataSourceSettings( "System.Data.SqlClient",
"Server=localhost;Database=Northwind;UID=myuser;PWD=mypass",sqlStr)
ds = DatabaseDataSource(dbsettings)
newDataTable = Document.Data.Tables.Add("temp",ds)
Document.Data.Tables.Remove(newDataTable)

以上來自Tibco Spotfire我已將其用作模板,使用 SQL 服務器中的表在Spotfire中創建票證系統。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM