John Beltran
John Beltran

Reputation: 73

Spotfire - Mark row in table based on Document Property Value through IronPython

I want to mark a row based on the value of a document value. For example, I would have a document property KeySet = K2. When I run the IronPython script, the row T2, K2, 2.00 should be marked.

I'm trying to follow

https://community.tibco.com/wiki/how-mark-visualization-based-unmarked-rows-another-visualization-tibco-spotfirer-using

and

https://community.tibco.com/wiki/how-mark-all-filtered-rows-table-using-ironpython-tibco-spotfirer

but I'm not too familiar with IronPython so I don't exactly know how to combine them to work like how I want.

Is this possible? Thank you.

Initial state:

enter image description here

After running the script, T2 is marked.

enter image description here

Upvotes: 0

Views: 2496

Answers (1)

John Beltran
John Beltran

Reputation: 73

Following is a sample script reference to mark rows based on document property selection

from Spotfire.Dxp.Data import *

selectedValue=Document.Properties["propertyName"]
#Create a cursor to refer a column which will have the values
table=Document.Data.Tables["tableName"]
cursor = DataValueCursor.CreateFormatted(table.Columns["columnName"])

rowCount = table.RowCount
#empty indexset
rowsToMark = IndexSet(rowCount,False)
for row in Document.ActiveDataTableReference.GetRows(cursor):
   rowIndex = row.Index
   if cursor.CurrentValue == selectedValue:
       rowsToMark.AddIndex(rowIndex)

Document.ActiveMarkingSelectionReference.SetSelection(RowSelection(rowsToMark),table)

Upvotes: 0

Related Questions