Jump to content

Select last value in List Box


veronique De Smet

Recommended Posts

Dear,

I have a list box with multipe dates in (Date/Time). Every time a new plan has been saved, a new date shows up in this List Box.

Problem is that the previous day is always selected and I want the last available day to be automatically selected when opening the dashboard.

I used below scipt, but this is not working. Can someone please help me out

from System import Array

from Spotfire.Dxp.Data import IndexSet

from Spotfire.Dxp.Data import DataValueCursor

tbl= Document.Data.Tables["DAILY_SCHEDULE_CHANGES"]

choicesCol = tbl.Columns["VersionLimit2"]

rowCount = tbl.RowCount

rowsToInclude = IndexSet(rowCount,True)

cursor1 = DataValueCursor.CreateFormatted(choicesCol)

strArray = Array.CreateInstance(str,rowCount)

for row in tbl.GetRows(rowsToInclude,cursor1):

rowIndex = row.Index

value1 = cursor1.CurrentValue

strArray[rowIndex-1] = value1

uniqueVal = list(set(strArray))

uniqueVal.sort()

Document.Properties["ReferenceSchedule"] = uniqueVal[10]

 

many thanks!

Link to comment
Share on other sites

You can use other approach as well:

1) You can create a simple calculated column say "selectDate" which will get the min/max date from your dataset as per you requirement, assuming this [Date] column's unique values are shown in Listbox:

Min([Date])2) Then in your script, you can just get the first row value from "selectDate"column and set the listbox property value with that row value.

from System import Array

from Spotfire.Dxp.Data import IndexSet

from Spotfire.Dxp.Data import DataValueCursor

 

tbl= Document.Data.Tables["DAILY_SCHEDULE_CHANGES"]

choicesCol = tbl.Columns["selectDate"]

rowCount = tbl.RowCount

rowsToInclude = IndexSet(rowCount,True)

 

cursor1 = DataValueCursor.CreateFormatted(choicesCol)

value=''

for row in tbl.GetRows(rowsToInclude,cursor1):

rowIndex = row.Index

value = cursor1.CurrentValue

break;

my_list = []

my_list.append(value)

 

#mylist1 = multi select list box property control

Document.Properties["mylist1"]=my_list

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...