This article illustrates how to select the first available value in drop down instead of a dash, using IronPython in Spotfire®
Introduction
If you have a drop-down document property showing values from a column, initially a DASH is displayed. If you want the drop down list property control to display the first value in the column, use the following script. The script looks ahead for the data in this particular column and sets the attached document property value to the first value found.
Code sample
# Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license. from System import Array from Spotfire.Dxp.Data import IndexSet from Spotfire.Dxp.Data import DataValueCursor # Get table tbl= Document.Data.Tables["Users"] # Get access to the Column populating the choice values # of the drop-down list control choicesCol = tbl.Columns["AccountTypeCode"] rowCount = tbl.RowCount rowsToInclude = IndexSet(rowCount,True) # Create a cursor to the Column we wish to get the values from cursor1 = DataValueCursor.CreateFormatted(choicesCol) # Create Array object that will hold values strArray = Array.CreateInstance(str,rowCount) # Loop through all rows, retrieve value for specific column, # and add value into array for row in tbl.GetRows(rowsToInclude,cursor1): rowIndex = row.Index value1 = cursor1.CurrentValue strArray[rowIndex-1] = value1 # Get only unique Values, cast to a list uniqueVal = list(set(strArray)) # Order list uniqueVal.sort() # Set document property to first value found in the list Document.Properties["AccountType"] = uniqueVal[0]
References
License: TIBCO BSD-Style License
Recommended Comments
There are no comments to display.