# Custom method to style cells

**URL:** <https://forum.inductiveautomation.com/t/custom-method-to-style-cells/90219>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 10, 2024, 10:47am UTC](https://forum.inductiveautomation.com/t/custom-method-to-style-cells/90219 "2024-05-10T10:47:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [May 10, 2024, 10:47am UTC](https://forum.inductiveautomation.com/t/custom-method-to-style-cells/90219/1 "2024-05-10T10:47:37Z")

</div>

Just added a custom method to change the color of the background of my table cells depending of the content, but doesn´t seem to work

```python
def style_transform(self, value):

    if value == 0:
        return {'backgroundColor': 'red', 'color': 'white'}
    elif value == 1:
        return {'backgroundColor': 'green', 'color': 'white'}
    else:
        return {}

return style_transform(value)

```

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [May 10, 2024, 11:16am UTC](https://forum.inductiveautomation.com/t/custom-method-to-style-cells/90219/2 "2024-05-10T11:16:33Z")

</div>

> [@Alejandro\_Alaco](#):
>
> ```python
> def style_transform(self, value):
> 
> if value == 0:
> return {'backgroundColor': 'red', 'color': 'white'}
> elif value == 1:
> return {'backgroundColor': 'green', 'color': 'white'}
> else:
> return {}
> 
> return style_transform(value)
> 
> ```

Hello I think you can create styles and try something like :

```python
 if value == 0:
        return {"classes": "table/Row1_1"} #red style
    elif value == 1:
        return {"classes": "table/Row1_2"} #blue style
    else:
        return "#000000" #defaut style

```

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [May 10, 2024, 11:28am UTC](https://forum.inductiveautomation.com/t/custom-method-to-style-cells/90219/3 "2024-05-10T11:28:06Z")

</div>

Thanks Sebastiao
