I have a dropdown Customers
and a dropdown Locations
. Locations dropdown options are based on what is selected in the customers dropdown. I wanted to make it so that if the lcoations dropdown only had two options (A ‘Select …’ which we have as a row hardcoded into our named query, and something else), we’d automatically select the location.
I have a value change script on my Customer value. When it changes, if auto-select is on, see if the location only has two rows, grab the value of the none ‘Select…’ row, and pick it.
if autoSelectOn:
data = self.getSibling("DD_Locations").props.options
dataRows = data.getRowCount()
system.perspective.print("Location has %i rows"%(dataRows))
if dataRows == 2 :
for row in range(dataRows):
value = data.getValueAt(row, 0)
system.perspective.print("Value: " + str(value))
if value != -2:
system.perspective.print("We got the value to change location to")
self.getSibling("DD_Locations").props.value = value
break
Here’s what I notice happening. If I have a customer with 30 locations, and then switch to a customer with only 2 locations (including ‘Select…’), the system.perspective.print("Location has %i rows"%(dataRows))
says that there are 30 rows. So it’s grabbing the options of my locations before they seem to have a chance to update. So this isn’t working at all. I tried doing a self.getSibling("DD_Locations").refreshBinding('props.options')
before I assign data = self.getSibling("DD_Locations").props.options
but it did not do anything. I know there’s no system.util.invokeLater with perspective. Is there a way around this?
It seems like I have a race condition where my customer value change script runs and finishes before location data is updated appropriately for my customer script to make sense.