# Power table row selection background conflict

**URL:** <https://forum.inductiveautomation.com/t/power-table-row-selection-background-conflict/14634>\
**Category:** Ignition\
**Created:** [June 27, 2017, 2:25am UTC](https://forum.inductiveautomation.com/t/power-table-row-selection-background-conflict/14634 "2017-06-27T02:25:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [June 27, 2017, 2:25am UTC](https://forum.inductiveautomation.com/t/power-table-row-selection-background-conflict/14634/1 "2017-06-27T02:25:35Z")

</div>

I have a power table which i want to be able to select a row, and then do various actions with buttons on the selected row. I want to highlight the selected row with the default selection colors Ignition implements.

However I also want to highlight a row based on some other condition, for example if a BOOL value in that row is high.  
I wrote the following code in the “configureCell” extension function of the Power Table:

```auto
	testDue = self.data.getValueAt(rowIndex, "TaskDue")
	if testDue:
		return {'background': '#8AFF8A'}
	else:
		return {'background': 'white'}
	# end if

```

This highlights the desired rows green.

My problem is, i can no longer get the Selected Row highlight to work. I assumed that because there are different properties for “selectedBackground” and “background” that they would remain separate. But there is some conflict here.

Is it possible to do what i am trying?

Thanks a bunch.

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [June 27, 2017, 12:22pm UTC](https://forum.inductiveautomation.com/t/power-table-row-selection-background-conflict/14634/2 "2017-06-27T12:22:17Z")

</div>

You need to capture it in your script.

Conveniently, there’s a “selected” parameter for every cell given as function argument, so you can just use that to color it.

```auto
testDue = self.data.getValueAt(rowIndex, "TaskDue")
if selected:
	return {'background': 'orange'}
elif testDue:
	return {'background': '#8AFF8A'}
else:
	return {'background': 'white'}

```

What I did in the past was working with the HSL color space. With HSL, you can assign a hue to a certain state, and then change the saturation and lightness for the selected row. That way, the colors remain consistent and users still see which rows are selected.

You can find quite a few HSL to RGB and back conversion algorithms on the net. Just watch out of the bounds (values from 0 to 1, from 0 to 255, from 0 to 360, …).

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [June 27, 2017, 10:04pm UTC](https://forum.inductiveautomation.com/t/power-table-row-selection-background-conflict/14634/3 "2017-06-27T22:04:29Z")

</div>

Ah brilliant. Got a bit mixed up with what i thought was “Cell” selected and the entire “Row” being selected. But I guess if a row has been selected, then each cell in that row is configured individually as specified in the script.

The HSL idea sounds nice. I’ll look into that as well.

Thanks!

---

<div class="post-metadata">

**Author:** ![qliu](https://avatars.discourse-cdn.com/v4/letter/q/bc8723/32.png) [@qliu](https://forum.inductiveautomation.com/u/qliu)\
**Post date:** [January 7, 2021, 1:33pm UTC](https://forum.inductiveautomation.com/t/power-table-row-selection-background-conflict/14634/4 "2021-01-07T13:33:22Z")

</div>

Thank you so much! So the if selected must cover the testDue part, correct?

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [January 19, 2021, 3:15am UTC](https://forum.inductiveautomation.com/t/power-table-row-selection-background-conflict/14634/5 "2021-01-19T03:15:29Z")

</div>

What do you mean exactly? The code posted above has worked for me as intended.  
I am actually using the code below in production now, adding an additional color for if the task is “overdue”.

```auto
	# Define initial dictionary to return
	formatDict = {'background': 'white'}
	
	# If test is due, format cell to make it stand out. 
	testDue = self.data.getValueAt(rowIndex, "TaskDue")
	testOverdue = self.data.getValueAt(rowIndex, "TaskOverdue")
	if selected:
		formatDict['background']= self.selectionBackground
	elif testOverdue:
		formatDict['background']= 'F57E59'
	elif testDue:
		formatDict['background']= 'F5CD64'
	else:
		formatDict['background']= 'white'
	# end if
	
	return formatDict

```

---

<div class="post-metadata">

**Author:** ![qliu](https://avatars.discourse-cdn.com/v4/letter/q/bc8723/32.png) [@qliu](https://forum.inductiveautomation.com/u/qliu)\
**Post date:** [January 19, 2021, 1:41pm UTC](https://forum.inductiveautomation.com/t/power-table-row-selection-background-conflict/14634/6 "2021-01-19T13:41:05Z")

</div>

Thank you sir!
