Perspective table not accepting edits

My question is similar to this one, Not able to edit Ignition Perspective table. I have a table that has a query binding with the return format being a dataset. (not polling). The edit box appears but when I hit the enter key the edit goes away. I have created columns with the appropriate field name which got me this far. I do not have a transform do I need one? Also, this would be icing on the cake but is there any way to make the spin box go away? The behavior is the same on the web page and designer. Thanks.

You need to use an onEditCellCommit event script to handle the change.

  • Right-click on the table and select Configure Events ...
  • Configure as shown below.

Figure 1. Note the self and event hyperlinks. These open a popup to show what properties are available.

Code:

def runAction(self, event):
	row = event.row
	col = event.column
	self.props.data[row][col] = event.value

That should get you as far as updating the table display. You probably also want to update the underlying database. The best way for that is to have an id row or unique key for use in an SQL UPDATE query and use that to update the whole row.

1 Like

I followed these steps which produced the following error:

Error running action 'component.onEditCellCommit' on Schedule@D/root/Table: Traceback (most recent call last): File "function:runAction", line 4, in runAction TypeError: 'com.inductiveautomation.ignition.gateway.datasource.BasicStreamingDataset' object is unsubscriptable

That is because the data is a Dataset. The above would work if the query binding's return format was JSON. Datasets are immutable, you will need to use the system.dataset.setValue().
https://docs.inductiveautomation.com/display/DOC81/system.dataset.setValue

row = event.row
col = event.column
self.props.data = system.dataset.setValue(self.props.data, row, col, event.value)
2 Likes

I'd like to point out that the alternative to this is to change the return format of the query to json.
It's sort of implied in William's answer, but we might as well make it clear.

I usually use json format, especially if I need to do operations on the data. It's much easier than the dataset option.

2 Likes