Power Table triggering twice onCellEdited in 7.9.21?

Been a long day I don't know if I am missing something simple. I am using Ignition 7.9.21 Vision with a power table onCellEdited extension function. My task is simple, let a user modify a column and update it in the database table.

My script on the onCellEdited extension is pretty simple imo -

print 'triggered %s %s'%(str(oldValue), str(newValue))
if system.gui.confirm("Are you sure you want to update CSV column name from %s to %s?"%(str(oldValue), str(newValue))):
	idx = self.data.getValueAt(rowIndex, 'idx')
	print 'idx %i type %s'%(idx, str(type(idx)))
	params = {'csvColumn':str(newValue), 'idx':idx}
	print 'params %s'%(str(params))
	system.db.runNamedQuery('CSV/update', params)
	print 'ran q'
	system.db.refresh(self, 'data')
	print 'refreshing'

When I click on the cell, edit the text, the onCellEdited gets triggered twice (but only if I have my full script).

When I have my full script the print statements read

triggered blah blah2
triggered blah blah2
idx 1 type <type 'int'>
params {'idx': 1, 'csvColumn': 'blah2'}
ran q
refreshing
idx 1 type <type 'int'>
params {'idx': 1, 'csvColumn': 'blah2'}
ran q
refreshing

And I get the system.gui.confrimation appears twice. If I remove my syste.gui.confirm and only have the top print statement, I get what I would expect when I edit the text and hit enter - only one print statement of the change like so -

triggered blah blah3

Just the one change.

Why is it double firing when I have the rest of my script there? I see both print statements

triggered blah blah2
triggered blah blah2

before I see the first system.gui.confirm. I tried changing the Edit Click Count from 1 to 2. I know I could add a custom property to act as a lock and only run my script if it's available but I feel like I am just missing something simple here. What am I missing here?

Edit: Forgot to mention it's a power table.

We ran into that a loooong time ago and added an invokeLater call


	def runUpdate():
		import system
		if system.gui.confirm('Are you sure?', 'Do It',1):
			ID = self.data.getValueAt(rowIndex,"ID")
			query = "UPDATE SYS_Info SET " + colName + " = ? WHERE ID = ?"
			values = [newValue, ID]
			system.db.runPrepUpdate(query, values,database='MyDB')
			system.db.refresh(self,"data")
	if colName=='PA' and oldValue <> newValue:
		system.util.invokeLater(runUpdate)
	else:
		pass
2 Likes

It's an interaction with this. I think if you put it all in an invokeLater it'll work?

Or get rid of it by having a separate "edit mode" toggle in the UI. (I despise system.gui.confirm() and its modal peers. Just say no.)

2 Likes

Yea normally I do a table just for a list/detail type pattern where the table only lists entries and there is a popup to edit any entry, which is how it's done in the rest of the project. This was a last minute ask, for a admin configuration table that MIGHT need to be changed once a year, for only a single column of a 2 column table. So I was ok with doing it this way for this particular case. I agree with you in general and that is normally what I do.