configureEditor refresh

As far as I can tell the Extension Function configureEditor does not refresh. i.e. it only runs the first time the table opens. This means you can’t adjust a drop down list dynamically. Let me give you an example:

[code] import system
if colName == ‘Operator’:

creating a list of users that have are already showing up in this column

	usedusers = []
	for x in range(self.Count): #Count is a custom property (number of rows)
		usedusers.append(self.data.getValueAt(x,colName))

creating a list of tuples for the dropdown

	list = [('Fill me in','Fill me in')] #default value
	users = system.user.getUsers("default")
	for user in users:
		if ("Operator" in user.getRoles()) and (user.get(user.Username) not in usedusers):
			list.append((user.get(user.Username),user.get(user.Username)))
	return {'options': list}[/code]

The above code gives you a drop down list to fill in an “Operator” column. It determines available operators and also determines which operators have already been used in the column. Therefore, after using an operator to fill in row 1, that operator should no longer show up in the drop down list. Unfortunately, that operator still shows up and I think the only way to get that operator to no longer show up would be to close the window and re-open it. Not very dynamic! Anyone have an idea how to make the editor dynamically refresh?

I figured out how to make the drop down list dynamic! I changed to a regular Table from a Power Table and then followed the concept outlined by Travis in https://inductiveautomation.com/forum/viewtopic.php?f=70&t=7840&hilit=translatemap :thumb_right:

You can force the power Table extension function configureEditor to execute with :

event.source.parent.getComponent('Power table').data = None
system.db.refresh(event.source.parent.getComponent('Power table'),"data")

if for example powertable Data property is binded to an SQL query with polling mode Off

4 Likes