# Updating Table with onCellEditCommit

**URL:** <https://forum.inductiveautomation.com/t/updating-table-with-oncelleditcommit/56669>\
**Category:** Ignition\
**Tags:** scripting, database, perspective\
**Created:** [March 1, 2022, 2:26pm UTC](https://forum.inductiveautomation.com/t/updating-table-with-oncelleditcommit/56669 "2022-03-01T14:26:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Hrynciw](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@Robert\_Hrynciw](https://forum.inductiveautomation.com/u/Robert_Hrynciw)\
**Post date:** [March 1, 2022, 2:26pm UTC](https://forum.inductiveautomation.com/t/updating-table-with-oncelleditcommit/56669/1 "2022-03-01T14:26:59Z")

</div>

Hello, I am having a problem trying to figure this error out. The error is:

```auto
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
  File "<function:runAction>", line 4, in runAction
TypeError: 'com.inductiveautomation.ignition.gateway.datasource.BasicStreamingDataset' object is unsubscriptable

```

line 4 being “self.props.data[event.row][event.column] = valueToSet”

This simple script works while the table is not filtered by dropdowns; however, when filtered it will not allow the onCellEditCommit to replace the previous value. I’m assuming this is because the filtered results column/row doesn’t match up with the database column/row. The filter for the dropdowns are a simple “Select \* from database where line = :line, area = :area” etc. The full table onCellEditCommit code is this:

```auto
#allows cell to be edited
valueToSet = event.value
self.props.data[event.row][event.column] = valueToSet
	
#sets edited value immediately -- otherwise have to click elsewhere to set
self.props.selection.data[0].TrainingLevel = valueToSet

```

I figure I better include one of my dropdowns’ change scripts as well. This is the example of the line dropdown for filtering.

```auto
Line = self.props.value

system.db.runNamedQuery("TrainingLine", {"Line" :Line})
returnedData = system.db.runNamedQuery("TrainingLine", {"Line" :Line})
self.parent.parent.getChild("Table").props.data = returnedData

```

After the onCellEditCommit script, I have an update button that the user will click to insert this updated value to the database. I am trying to find an alternate way of using the onCellEditCommit so that it works with the filtered dropdowns. Any tips or advice is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 1, 2022, 2:44pm UTC](https://forum.inductiveautomation.com/t/updating-table-with-oncelleditcommit/56669/3 "2022-03-01T14:44:20Z")

</div>

> [@Robert\_Hrynciw](#):
>
> `BasicStreamingDataset`

the problem is your data is a dataset, you cant access or set a dataset like that.  
[https://docs.inductiveautomation.com/display/DOC81/Datasets](https://docs.inductiveautomation.com/display/DOC81/Datasets)  
[https://docs.inductiveautomation.com/display/DOC81/system.dataset.setValue](https://docs.inductiveautomation.com/display/DOC81/system.dataset.setValue)

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 1, 2022, 2:45pm UTC](https://forum.inductiveautomation.com/t/updating-table-with-oncelleditcommit/56669/4 "2022-03-01T14:45:16Z")

</div>

Seems you did an edit...

> [@Robert\_Hrynciw](#):
>
> `system.db.runNamedQuery("TrainingLine", {"Line" :Line})`

If you get the dataset from a database you will have to do an update to the database and not just create a new dataset

[https://docs.inductiveautomation.com/display/DOC81/system.db.runPrepUpdate](https://docs.inductiveautomation.com/display/DOC81/system.db.runPrepUpdate)

---

<div class="post-metadata">

**Author:** ![Robert\_Hrynciw](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@Robert\_Hrynciw](https://forum.inductiveautomation.com/u/Robert_Hrynciw)\
**Post date:** [March 1, 2022, 2:53pm UTC](https://forum.inductiveautomation.com/t/updating-table-with-oncelleditcommit/56669/5 "2022-03-01T14:53:08Z")

</div>

Sorry for the confusion, it’s hard to type these kinds of things out and this is my first forum post. That query is just to filter the line on the table to the selected input value on the line dropdown. I have an update button that runs the prep update.

```auto
update = "UPDATE Badge_Read_Training_Level SET TrainingLevel = ? WHERE Name = ? and Line = ? and Area = ? and Job = ?"
system.db.runPrepUpdate(update, args)

```

However this can’t go through unless the dataset is unfiltered. The filtering creates a new dataset and that is where the problem lies?

Also thank you very much for the help. I’m currently researching the links you sent.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 1, 2022, 3:20pm UTC](https://forum.inductiveautomation.com/t/updating-table-with-oncelleditcommit/56669/6 "2022-03-01T15:20:32Z")

</div>

I still am not sure i understand where all your functions go…

But try this  
`self.props.data = system.dataset.setValue(self.props.data, event.row , event.column,valueToSet)`

---

<div class="post-metadata">

**Author:** ![JHON\_FLOREZ](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JHON\_FLOREZ](https://forum.inductiveautomation.com/u/JHON_FLOREZ)\
**Post date:** [June 22, 2022, 1:12pm UTC](https://forum.inductiveautomation.com/t/updating-table-with-oncelleditcommit/56669/7 "2022-06-22T13:12:20Z")

</div>

saludos estoy configurando una tabla con onCellEdited uso la versión 7.9 este es mi código

```auto
row = rowIndex
col = colIndex
colName = colName

ID = self.data.getValueAt(rowIndex,'id')
query = "UPDATE AguaControl.Agua SET %s = ? WHERE id = ?" %(colName)
system.db.runPrepUpdate (query,ID,'AguaControl')
system.db.refresh(self,"data")

```

pero no me funciona no se donde esta el error podrian ayudarme
