# Set cell background by script

**URL:** <https://forum.inductiveautomation.com/t/set-cell-background-by-script/12811>\
**Category:** Ignition\
**Created:** [March 18, 2017, 5:59pm UTC](https://forum.inductiveautomation.com/t/set-cell-background-by-script/12811 "2017-03-18T17:59:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![StepanenkoPaul](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@StepanenkoPaul](https://forum.inductiveautomation.com/u/StepanenkoPaul)\
**Post date:** [March 18, 2017, 5:59pm UTC](https://forum.inductiveautomation.com/t/set-cell-background-by-script/12811/1 "2017-03-18T17:59:45Z")

</div>

Can I set the color for a row in a specific column by script?

---

<div class="post-metadata">

**Author:** ![StepanenkoPaul](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@StepanenkoPaul](https://forum.inductiveautomation.com/u/StepanenkoPaul)\
**Post date:** [March 19, 2017, 9:47am UTC](https://forum.inductiveautomation.com/t/set-cell-background-by-script/12811/2 "2017-03-19T09:47:14Z")

</div>

The problem solved 😃

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [March 19, 2017, 3:55pm UTC](https://forum.inductiveautomation.com/t/set-cell-background-by-script/12811/3 "2017-03-19T15:55:20Z")

</div>

Nice job. 🙂

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [March 19, 2017, 3:58pm UTC](https://forum.inductiveautomation.com/t/set-cell-background-by-script/12811/4 "2017-03-19T15:58:45Z")

</div>

> [@StepanenkoPaul](#):
>
> The problem solved 😃

Very good. ![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")

---

<div class="post-metadata">

**Author:** ![maripierdo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/maripierdo/32/16478_2.png) [@maripierdo](https://forum.inductiveautomation.com/u/maripierdo)\
**Post date:** [September 20, 2018, 7:36pm UTC](https://forum.inductiveautomation.com/t/set-cell-background-by-script/12811/5 "2018-09-20T19:36:59Z")

</div>

Please can you tell us, How was it solved?

---

<div class="post-metadata">

**Author:** ![StepanenkoPaul](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@StepanenkoPaul](https://forum.inductiveautomation.com/u/StepanenkoPaul)\
**Post date:** [September 21, 2018, 6:32am UTC](https://forum.inductiveautomation.com/t/set-cell-background-by-script/12811/6 "2018-09-21T06:32:33Z")

</div>

I needed to change the background of the cell depending on the value. I found a next decision:

add to your Table.Extention Functions something like this:

Column\_Value = self.data.getValueAt(row,‘Column\_Value’) #5th column

if col==5:   
if int(Column\_Value)==100:  
return “Red”  
elif int(Column\_Value)==50:  
return “Yellow”  
else:  
return defaultColor

P.S.: row & col are extension table attributes. They do not need to be created

---

<div class="post-metadata">

**Author:** ![maripierdo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/maripierdo/32/16478_2.png) [@maripierdo](https://forum.inductiveautomation.com/u/maripierdo)\
**Post date:** [September 21, 2018, 12:01pm UTC](https://forum.inductiveautomation.com/t/set-cell-background-by-script/12811/7 "2018-09-21T12:01:14Z")

</div>

Thank you so much, I could develop what I needed.  
I did the next script in the getBackgroundAt extension function in the table scripting:

```
procEnab_1 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_1").value
procEnab_2 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_2").value
procEnab_3 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_3").value
procEnab_4 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_4").value
procEnab_5 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_5").value
procEnab_6 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_6").value
procEnab_7 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_7").value
procEnab_8 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_8").value
procEnab_9 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_9").value
procEnab_10 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_10").value
procEnab_11 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_11").value
procEnab_12 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_12").value
procEnab_13 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_13").value
procEnab_14 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_14").value
procEnab_15 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_15").value
procEnab_16 = system.tag.read("[Client]INTERNAS/Receta_CIP_LK/TablaPasos/procEnab_16").value
selRow = self.selectedRow
#data
#colName = self.data.getColumnNames()[col]	
if row == selRow and col == 3 and procEnab_1 == 1:
	return "255,255,204"
elif row == selRow and col == 4 and procEnab_2 == 1:
	return "255,255,204"
elif row == selRow and col == 5 and procEnab_3 == 1:
	return "255,255,204"
elif row == selRow and col == 6 and procEnab_4 == 1:
	return "255,255,204"
elif row == selRow and col == 7 and procEnab_5 == 1:
	return "255,255,204"
elif row == selRow and col == 8 and procEnab_6 == 1:
	return "255,255,204"
elif row == selRow and col == 9 and procEnab_7 == 1:
	return "255,255,204"
elif row == selRow and col == 10 and procEnab_8 == 1:
	return "255,255,204"
elif row == selRow and col == 11 and procEnab_9 == 1:
	return "255,255,204"
elif row == selRow and col == 12 and procEnab_10 == 1:
	return "255,255,204"
elif row == selRow and col == 13 and procEnab_11 == 1:
	return "255,255,204"
elif row == selRow and col == 14 and procEnab_12 == 1:
	return "255,255,204"
elif row == selRow and col == 15 and procEnab_13 == 1:
	return "255,255,204"
elif row == selRow and col == 16 and procEnab_14 == 1:
	return "255,255,204"
elif row == selRow and col == 17 and procEnab_15 == 1:
	return "255,255,204"
elif row == selRow and col == 18 and procEnab_16 == 1:
	return "255,255,204"
else:
	return defaultColor

```

Thank for your help! Regards
