I created a table in Ignition Perspective with 2 columns and 4 rows. Each column has a name assigned. I want to make the second column editable, so I set the 'editable' property for that column to 'yes'. However, when I open the page in a web browser and try to edit the 'Desp' column, I enter some text and press enter, but the cell reverts to its original value. Did I miss setting up a property correctly?
You need to use an action on the table (onCellCommitted
or something like that) to write the new value back to the dataset at columnIndex, rowIndex. Does that make sense?
EDIT: Link to the docs:
1 Like
Is this correct script ?
But I got error logged.
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 3, in runAction TypeError: 'com.inductiveautomation.ignition.common.JsonDataset' object is unsubscriptable
at org.python.core.Py.TypeError(Py.java:234)
at org.python.core.PyObject.__finditem__(PyObject.java:653)
at org.python.core.PyObjectDerived.__finditem__(PyObjectDerived.java:920)
at org.python.core.PyObject.__getitem__(PyObject.java:717)
at org.python.core.PyObjectDerived.__getitem__(PyObjectDerived.java:960)
at org.python.pycode._pyx5551.runAction$1(:3)
at org.python.pycode._pyx5551.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyFunction.function___call__(PyFunction.java:474)
Datasets are immutable. Use the system.dataset.setValue() function to produce a new dataset with the edit, and assign that back to props.data
.
1 Like
How did he end up with a JsonDataset
though ?
I don't think I've ever seen this before.
Precisely what Phil said OR if you had a Query binding on props.data
, you could set the return type to JSON
and I believe you would be able to use your script. Right now, it's a Dataset type so you would need to do something like
valueToSet = event.value
newDS = system.dataset.setValue(self.props.data, event.row, event.column, valueToSet)
self.props.data = newDS
2 Likes
This works, thanks.