# Power Table Editing

**URL:** <https://forum.inductiveautomation.com/t/power-table-editing/100630>\
**Category:** Ignition\
**Tags:** vision, scripting\
**Created:** [January 9, 2025, 2:35am UTC](https://forum.inductiveautomation.com/t/power-table-editing/100630 "2025-01-09T02:35:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnny.1](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@johnny.1](https://forum.inductiveautomation.com/u/johnny.1)\
**Post date:** [January 9, 2025, 2:35am UTC](https://forum.inductiveautomation.com/t/power-table-editing/100630/1 "2025-01-09T02:35:52Z")

</div>

Hey everybody, i am new to using Ignition Designer and I need some help please. I have a power table with 3 columns and 52 rows. The last column i have put to editable meaning i can edit it during the preview or running mode.

The problem is, when i go on preview mode and edit a row in the 3 column, what i have put in does not seem to be seen on the table or saved on the row or cell im doing my editing. Can i please have some help with the scripting for power table to be able to save or make the value i put in stay or save in that cell, in pewview and editing mode please and thank you.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [January 9, 2025, 2:39am UTC](https://forum.inductiveautomation.com/t/power-table-editing/100630/2 "2025-01-09T02:39:41Z")

</div>

You have to use the `onCellEdited` method on the power table to write a script to send the new data to whatever data source you are using for the table.

If you are sourcing your table data from a DB, then your script would perform a DB insert or update.

> **[Vision - Power Table Scripting Functions | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/components/vision-components/tables/power-table/power-table-scripting-functions#oncelledited)**
>
> This page details the various component and extension functions available for Vision's Power Table component.

> **[Updating the Database through the Power Table | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/platform/sql-in-ignition/common-sql-tasks/updating-the-database-through-the-power-table)**
>
> Updating Table Data

---

<div class="post-metadata">

**Author:** ![johnny.1](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@johnny.1](https://forum.inductiveautomation.com/u/johnny.1)\
**Post date:** [January 9, 2025, 2:51am UTC](https://forum.inductiveautomation.com/t/power-table-editing/100630/3 "2025-01-09T02:51:02Z")

</div>

Thank you for responding. I do not have a data or DB, but rather I want to edit this row in the column and it will saved to a tag (memory dataset tag), but I just want to understand or know how to be able to make the table be edited during preview mode and the value i put in during this mode, it will show or be saved during and after preview mode. Please and thank you

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 9, 2025, 3:13am UTC](https://forum.inductiveautomation.com/t/power-table-editing/100630/4 "2025-01-09T03:13:55Z")

</div>

@ryan.white's answer is correct. For your use case, simply use the onCellEdited extension function to create an updated dataset from the data property of the power table. Then, [write](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-writeBlocking) the new value to the tag.

I assume you have the power table's data propery bound to the tag value?

---

<div class="post-metadata">

**Author:** ![johnny.1](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@johnny.1](https://forum.inductiveautomation.com/u/johnny.1)\
**Post date:** [January 9, 2025, 3:22am UTC](https://forum.inductiveautomation.com/t/power-table-editing/100630/5 "2025-01-09T03:22:31Z")

</div>

```python
table = event.source.parent.getComponent('powertable')

    rowIndex = event.rowIndex  
    colIndex = event.columnIndex  

    if colIndex == 2:
        newValue = event.newValue
        dataset = system.tag.read("[default]Dataset").value
        
    dataList = dataset.getDataAsList()

    for i in range(len(dataList)):
        if i == rowIndex:
            dataList[i][colIndex] = newValue

        updatedDataset = system.dataset.toDataset(dataset.getColumnNames(), dataList)
        system.tag.write("[default]Dataset", updatedDataset)

        print("Row {rowIndex}, Operator column updated with value: {newValue}")

```

And yes, the power table data property is bound to the tag value (Dataset)

But this code does not seem to work or do what i want. What have a done wrong here. (Thank you for you response and help by the way.)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 9, 2025, 3:30am UTC](https://forum.inductiveautomation.com/t/power-table-editing/100630/6 "2025-01-09T03:30:13Z")

</div>

That script looks way more complex than it should be. I would imagine it should look more like this:

```python
#def onCellEdited(self, rowIndex, colIndex, colName, oldValue, newValue):
	newData = system.dataset.setValue(self.data, rowIndex, colIndex, newValue)
	system.tag.writeBlocking(['path/to/tag'], [newData])

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 9, 2025, 5:18pm UTC](https://forum.inductiveautomation.com/t/power-table-editing/100630/7 "2025-01-09T17:18:34Z")

</div>

A digression, but I think if you make the binding to the tag bidirectional the script could literally just be:

```python
self.data = system.dataset.setValue(self.data, rowIndex, colIndex, newValue)

```

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 10, 2025, 1:52am UTC](https://forum.inductiveautomation.com/t/power-table-editing/100630/8 "2025-01-10T01:52:13Z")

</div>

> [@paul-griffith](#):
>
> the script could literally just be:

You gotta love Ignition. Just when it seems it can't get any simpler, it does! 🤣

---

<div class="post-metadata">

**Author:** ![johnny.1](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@johnny.1](https://forum.inductiveautomation.com/u/johnny.1)\
**Post date:** [January 10, 2025, 7:44pm UTC](https://forum.inductiveautomation.com/t/power-table-editing/100630/9 "2025-01-10T19:44:58Z")

</div>

Thank you very much for your helps, appreciate it and wish you guys an entertaining 2025
