# How to capture when in table cell edit

**URL:** <https://forum.inductiveautomation.com/t/how-to-capture-when-in-table-cell-edit/10700>\
**Category:** General Discussion\
**Created:** [October 30, 2015, 4:33pm UTC](https://forum.inductiveautomation.com/t/how-to-capture-when-in-table-cell-edit/10700 "2015-10-30T16:33:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerry101](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jerry101](https://forum.inductiveautomation.com/u/jerry101)\
**Post date:** [October 30, 2015, 4:33pm UTC](https://forum.inductiveautomation.com/t/how-to-capture-when-in-table-cell-edit/10700/1 "2015-10-30T16:33:42Z")

</div>

what event could i use to know when a table cell is being edited? I want to change the font color while in edit . “cellEdited” event is after it is edited and that does me no good.

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [October 30, 2015, 9:06pm UTC](https://forum.inductiveautomation.com/t/how-to-capture-when-in-table-cell-edit/10700/2 "2015-10-30T21:06:48Z")

</div>

On the ConfigureEditor extension function, set the foreground color.

```auto
return {"foreground":"red"}
```

---

<div class="post-metadata">

**Author:** ![jerry101](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jerry101](https://forum.inductiveautomation.com/u/jerry101)\
**Post date:** [November 1, 2015, 4:00pm UTC](https://forum.inductiveautomation.com/t/how-to-capture-when-in-table-cell-edit/10700/3 "2015-11-01T16:00:20Z")

</div>

Well i am using the standard table and was looking for a solution for it. I may have to change to a Power Table if i can’t work around it. Thanks though.

---

<div class="post-metadata">

**Author:** ![jerry101](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jerry101](https://forum.inductiveautomation.com/u/jerry101)\
**Post date:** [November 5, 2015, 4:07pm UTC](https://forum.inductiveautomation.com/t/how-to-capture-when-in-table-cell-edit/10700/4 "2015-11-05T16:07:35Z")

</div>

So i have changed to the Power Table and using the suggested ‘return {“foreground”:“red”}’ and this works while editing. Now i want to keep the red after edit to highlight changes. I am not updating the database after edit, i am just creating a new dataset to collect all changes and then will update my database with a ‘save’ button. How can i apply the foreground color after edit? The code below never returns the foreground color. Is this because it is a new dataset?

onCellEdited

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

return {"foreground":"red"}
```

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [November 5, 2015, 5:02pm UTC](https://forum.inductiveautomation.com/t/how-to-capture-when-in-table-cell-edit/10700/5 "2015-11-05T17:02:27Z")

</div>

[quote=“jerry101”]So i have changed to the Power Table and using the suggested ‘return {“foreground”:“red”}’ and this works while editing. Now i want to keep the red after edit to highlight changes. I am not updating the database after edit, i am just creating a new dataset to collect all changes and then will update my database with a ‘save’ button. How can i apply the foreground color after edit? The code below never returns the foreground color. Is this because it is a new dataset?

onCellEdited

[code]  
import system  
self.data = system.dataset.setValue(self.data, rowIndex, colIndex, newValue)

return {“foreground”:“red”}  
[/code][/quote]

My suggestion is to add a hidden column to your table dataset named “original value” or something similar.

Then all you have to do in the edit event is to compare the current cell value to the value in the original value column. If they don’t match then return red for the background color.

With this method the cell only gets highlighted once the user actually changes the value. Plus if they change it back the highlighting goes away.

When you do save the data you can sort through to the dataset to find only the values that have been changed by comparing the 2 columns.
