How can I restrict table cell data entry to numeric value (and backspace / delete / . / + / -) only? There is no customizer available. (Ignition 8.0.)
Do I have to script in the keyPressed or keyTyped event? It seems like something that should be built-in.
Why is no customizer available?
Aside from that, in tricky cases, you can generate custom cell editors for the Power Table. These posts cover many cases:
http://forum.inductiveautomation.com/search?q=TableCellEditor
Sorry, Paul. I worded that badly.
The table customizer is available but has no options for “numeric only” or keypress filtering.
I had already had a good look through the forum and web search but didn’t find an answer.
Thank you.
Sorry, Phil, for the misnomer. (I remembered the first and last letters only.)
I solved the problem as follows. Note that I only want column 2 to be editable.
- On the Power Table scripting editor enable the isCellEditable extension function. Add in:
if colIndex == 2:
return True
else:
return False
- Enable the onCellEdited extension function and add in something like this:
errMsg = ''
try:
# Test if newValue is a valid float.
newValue = float(newValue)
except ValueError:
errMsg = 'Invalid number value entered: ' + str(newValue)
if errMsg <> '':
system.gui.messageBox(errMsg, 'Sorry')
# The oldValue will automatically reappear.
else:
newData = system.dataset.setValue(self.data, rowIndex, colIndex, str(newValue))
self.data = newData
# Update the CSV file.
Now to update the CSV file!