I have a script that runs on a dropdown value change script that affects another drop downs options. The value change script is like this
import components.dropdowns
components.dropdowns.setOptions(self.getSibling("DD_Locations"), "listlocations", "name")
and setOptions is
def setOptions(dropDown, dbTable,labelColumn, where=None, placeHolder=True, valueColumn="idx"):
"""
Handles setting options on dropdowns using convetions of a -2 value with label "Select ..."
Args:
dropDown: reference to the dropdown
dbTable: str, name of the database table to query from
labelColumn: str, name of column in database table to grab labels from
filter: str, if you need a WHERE clause, enter it into this parameter like "WHERE parentCustomerId = 54" with no spaces on either side
placeHolder: boolean, default is True, if True, create top row for the dropdown with value -2 and label "Select..."
valueColumn: str, name of the column you want to be the value in the dropdown, default is idx
Returns:
Nothing, sets the value of the dropdown
"""
import system.db
placeHolderQuery = "SELECT -2 as 'Value', 'Select...' as 'Label' UNION"
optionsQuery = """
SELECT %s as 'Value', %s as 'Label'
FROM %s
%s
ORDER by Label
"""%(valueColumn, labelColumn, dbTable, where)
if placeHolder:
finalQuery = placeHolderQuery + optionsQuery
else:
finalQuery = optionsQuery
data = system.db.runQuery(finalQuery)
system.perspective.print(finalQuery)
system.perspective.print(str(data))
dropDown.props.options = data
But then changing my customers dropdown, I start getting this error in designer on repeat which disallows me from changing anything else or saving the project, I have to exit.
09:06:04.089 [Browser Events Thread] INFO Perspective.Designer.BrowserConsole - [mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: 'Reaction[m#undefined.render()]'
The reason we’re doing this by the way was because, and I couldn’t figure out way, occasionally the bindings of certain components would seem to not fire, so I was told by a superior to just make it all happen programatically so we could have more control. I have limited experience with React but I know it needs to know about all changes on the front end and maybe I’m circumventing that in a bad way here? Any ideas?