Power Table ConfigureCell/ConfigureEditor

Hi Everyone,

I’m trying to make a dynamic dropdown (from sql based on another parameter on the window) in a specific column on a power table however it seems like the only way to do this is from the “configure editor” extension function. In an ideal world i’d use the configure cell function and only execute when the column index is the column i want as it allows me even more flexibility by being able to reference other cells in the row of that column to help with parsing my dropdown list of tuples. I have it working but not the way i’d like from configure editor, problem is based on the documentation configure editor only executes when the table first loads and won’t update when the data updates (aka i change my dynamic parameter on the window). Wondering if there’s a way to call an extension function on property change of the data or from another extension function or something to help with that. Also if anyone knows how to configure a list of tuples into a cell from configure cell rather than configure editor that would be my ideal scenario. Below is code from my ConfigureEditor that works but does not update when the data updates:

def pds_to_tuples(pds):
	return map(lambda r: tuple([c for c in r]), pds)

cell = self.parent.getComponent('MES Object Selector').equipmentItemPath
if cell == system.tag.read('[client]Client Equipment Path').value:
	cell = system.tag.read('[client]Client Equipment Path').value + "\Filler"
#print cell

AlarmData = system.db.runPrepQuery("Select AlarmID, AlarmDescription From MES_Alarm_Lookup where equipmentUUID = ? and SecondaryAlarm = 1 order by AlarmID asc",[cell],system.tag.read("[System]Client/System/DefaultDatabase").value)
if colName == 'Alarm Description' and cell != "":
	return {'options':pds_to_tuples(AlarmData)}

@michael.walter, I moved this post out to a new thread.

I would encourage taking a look at my post in another thread, solving essentially the problem you're describing:

Note that, as @pturmel (correctly) likes to point out, you would not want to do something blocking like system.db.runPrepQuery directly in a frontend call - those scripts block the event dispatch thread, meaning your client will hang up entirely if that query ever returns slowly.

what exactly do you mean by a frontend call. pardon my ignorance. and how would i do that on the backend then but still be able to use it in an extension function

Basically, just let us do it for you. If you move your query to a query binding on a dataset property, we’ll manage the polling and do it asynchronously. Then in your script, you just refer to that custom property, which is “safe” - since it won’t directly run the query, just refer to whatever value the custom property has at that moment.

ok gotcha. make sense thanks

based on your script i got mine working other than the fact that what i really want is it to be a tupple for the dropdown that only shows the second column in the dropdown but has a value associated with it. right now its literally listing out my tupple in the dropdown. is there any way to make it as i just described?powertabletupple