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.