# Highlight last row in a table

**URL:** <https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 8, 2024, 6:05am UTC](https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907 "2024-01-08T06:05:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [January 8, 2024, 6:05am UTC](https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907/1 "2024-01-08T06:05:53Z")

</div>

Hi,  
I have a perspective table that returns dataset with (last row (9th row) as sum of each column).  
To differentiate i would like to highlight only last row with different background color. I could posts related to json, how to do it for dataset and where to write.  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 8, 2024, 6:54am UTC](https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907/2 "2024-01-08T06:54:28Z")

</div>

You can't.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 8, 2024, 6:57am UTC](https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907/3 "2024-01-08T06:57:03Z")

</div>

You can always use a transform to convert your dataset to a JSON:

```auto
#def transform(self, value, quality, timestamp):
	dataList = []
	for row in range(value.rowCount):
		rowDict={}
		for column in value.columnNames:
			rowDict[column] = value.getValueAt(row, column)
		dataList.append(rowDict)
	return dataList

```

Then you should be able to change the background of whatever row index you want.

**Edit:** Removed encoding; that wouldn't be needed for this.

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [January 8, 2024, 7:09am UTC](https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907/4 "2024-01-08T07:09:13Z")

</div>

But i have added render view for few columns. So i would like to do this highlighting in dataset itself

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 8, 2024, 7:13am UTC](https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907/5 "2024-01-08T07:13:34Z")

</div>

Is it always going to be the same number of rows? If so, perhaps you could simply overlay a label with a semi-transparent background to give the 9th row the illusion of being highlighted.

...or sum your columns in labels under the table instead of in the last row of the table

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [January 8, 2024, 7:14am UTC](https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907/6 "2024-01-08T07:14:47Z")

</div>

Yes its going to be same number of rows. How to overlay only for this row

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [January 8, 2024, 2:04pm UTC](https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907/7 "2024-01-08T14:04:20Z")

</div>

You can't within the dataset itself. Instead, just set the selected row value to the last row.  
or

> [@justinedwards.jle](#):
>
> ...or sum your columns in labels under the table instead of in the last row of the table

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 8, 2024, 2:09pm UTC](https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907/8 "2024-01-08T14:09:32Z")

</div>

Or add a second table with the totals below the first. Suppress the footers on the first and suppress the headers on the second.

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [November 29, 2024, 6:21am UTC](https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907/9 "2024-11-29T06:21:54Z")

</div>

I have fixed this using style sheet.

```python
.psc-row{
	background-color:white;
	}
.psc-row:nth-last-child(2){
	background-color:#DCEDC8;
	font-weight:bold;
}
.psc-row:nth-last-child(1){
	background-color:#D7CCC8;
	font-weight:bold;
}

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [November 29, 2024, 8:00am UTC](https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907/10 "2024-11-29T08:00:18Z")

</div>

Good solution.  
I suggest you give a more specific name to your classes though, `row` is VERY broad.

Note: You can also use column footers for totals.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 29, 2024, 9:29am UTC](https://forum.inductiveautomation.com/t/highlight-last-row-in-a-table/83907/11 "2024-11-29T09:29:08Z")

</div>

And I recommend that you use [Built-in Theme Colors](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/styles/perspective-built-in-themes#built-in-theme-colors) as much as possible as these will self-adjust and preserve contrast if you ever change your theme.
