#This script finds selected items in a cross table so you can pass them to a stored procedure or something
from Spotfire.Dxp.Application.Visuals import VisualContent
from Spotfire.Dxp.Data import DataValueCursor
from Spotfire.Dxp.Data import IndexSet
from Spotfire.Dxp.Data import RowSelection
from Spotfire.Dxp.Data import DataPropertyClass
myCol = "phoneBrands"
items=""
#vis can be a script parameter pointing to a Cross Table Visualization
vc=vis.As[VisualContent]()
dataTable=vc.Data.DataTableReference
marking=vc.Data.MarkingReference
#1 Create a cursor to the Column we wish to get the values from
#You can use any column you want from the datatable
markedItems = marking.GetSelection(dataTable)
cursor = DataValueCursor.CreateFormatted(dataTable.Columns[myCol])
#2 loop all rows
i=0
for row in dataTable.GetRows(cursor):
#2.A if the row is marked..
if markedItems.AsIndexSet()[i] == True:
#2.A.1 add an item if the item is not already in the items string
#you can pass this string to a stored procedure. Example output: "nokia,samsung,sony,apple,"
if items.find(cursor.CurrentValue)==-1:
items = items + "," + str(cursor.CurrentValue).Replace("'","''")
i = i + 1
ConversionConversion EmoticonEmoticon