# Table (not Power Table) and cell background color

**URL:** <https://forum.inductiveautomation.com/t/table-not-power-table-and-cell-background-color/76283>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [July 12, 2023, 10:05pm UTC](https://forum.inductiveautomation.com/t/table-not-power-table-and-cell-background-color/76283 "2023-07-12T22:05:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwoo](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@dwoo](https://forum.inductiveautomation.com/u/dwoo)\
**Post date:** [July 12, 2023, 10:05pm UTC](https://forum.inductiveautomation.com/t/table-not-power-table-and-cell-background-color/76283/1 "2023-07-12T22:05:23Z")

</div>

Is there a way to change a cell's background color if the cell's value has changed, data type doesn't matter (string, numeric, boolean...)?

I could use a power table, but the issue is there's no easy way to highlight the current cell's value in a dropdown list.. This is a default feature in a Table. There's an extension function that will return a cell fore/background color but none to set it.

---

<div class="post-metadata">

**Author:** ![dwoo](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@dwoo](https://forum.inductiveautomation.com/u/dwoo)\
**Post date:** [July 13, 2023, 2:05pm UTC](https://forum.inductiveautomation.com/t/table-not-power-table-and-cell-background-color/76283/2 "2023-07-13T14:05:09Z")

</div>

Figured it out, I used a global list of list to track the cell changed by saving a [row,col] list into a  
Changetracking list in the cellEdited() event handler. In the getBackgroundAt() extension function create a list of the current cell location , Currcell = [row,col] and check if the list is in the Changetracking list, if so change it's color

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/f/5fb938d90ecf986da375706842b21a7125721b68.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/8/685c2a4b9f2c3217762aa0b4d5565a6a5cf69638.png)

Remember to define the "global" list in a project script and clear the "global" list in the screen's startup() event.

---

<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:** [July 13, 2023, 3:21pm UTC](https://forum.inductiveautomation.com/t/table-not-power-table-and-cell-background-color/76283/3 "2023-07-13T15:21:35Z")

</div>

I would store a _set_ on the local table using [`putClientProperty`](https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/JComponent.html#putClientProperty(java.lang.Object,java.lang.Object)) and `getClientProperty` - use a tuple `(row, col)` as the key. Sets are O(1) ~constant time lookup, where arrays or lists have to be scanned completely, meaning O(n) lookup (the time to retrieve a value gets longer the more items there are in the list).

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 13, 2023, 3:31pm UTC](https://forum.inductiveautomation.com/t/table-not-power-table-and-cell-background-color/76283/4 "2023-07-13T15:31:49Z")

</div>

I recommend creating a custom dataset property to hold the unmodified table, and move the original `data` binding to it. Then unidirectionally bind `data` to the custom property. This yields the same editing behavior you now have, but you won't have to maintain a change list. Just compare the supplied `value` to the corresponding entry in the unmodified dataset, using the row and column given. `Dataset.getValueAt()` is also O(1). This approach has the nice side-effect that re-editing a cell back to it original will remove its highlight.
