# Styling Rows only showing most recent row

**URL:** <https://forum.inductiveautomation.com/t/styling-rows-only-showing-most-recent-row/105335>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 21, 2025, 4:20pm UTC](https://forum.inductiveautomation.com/t/styling-rows-only-showing-most-recent-row/105335 "2025-04-21T16:20:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Ford-King](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Alex\_Ford-King](https://forum.inductiveautomation.com/u/Alex_Ford-King)\
**Post date:** [April 21, 2025, 4:20pm UTC](https://forum.inductiveautomation.com/t/styling-rows-only-showing-most-recent-row/105335/1 "2025-04-21T16:20:51Z")

</div>

I have a data table and I'm trying to follow the manual to change the row colors based on values. When using this script.

```python
def transform(self, value, quality, timestamp):
	# Ensure the value is a list (your case: list of dicts)
	#if not isinstance(value, list):
    	#	return value

	styledRows = []

	for row in value:
    # Copy the original row to avoid mutating it
    		newRow = dict(row)

    # Get the 'Inspected' value (defaults to False if missing)
    	inspected = row.get("Inspected", False)

    # Apply row-level style
    	newRow[" __style__"] = {
        "backgroundColor": "#d4edda" if inspected else "#f8d7da", # light green / red
        "color": "#155724" if inspected else "#721c24", # dark green / red text
        "fontWeight": "bold"
    }

    	styledRows.append(newRow)

	return styledRows

```

This script is a transform on a query binding with a json type. It only shows 1 row when i apply it and does not change the row colors at all.

Any help would be appreciated

---

<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:** [April 21, 2025, 4:23pm UTC](https://forum.inductiveautomation.com/t/styling-rows-only-showing-most-recent-row/105335/2 "2025-04-21T16:23:07Z")

</div>

Before going into any other issues with this (probably LLM generated) script, try fixing your indentation. You **must** use **consistent** indentation in Python; your script as posted is alternating tabs and spaces, so what code is actually running is not easy to determine:

```python
def transform(self, value, quality, timestamp):
	# Ensure the value is a list (your case: list of dicts)
	#if not isinstance(value, list):
		#	return value

	styledRows = []

	for row in value:
		# Copy the original row to avoid mutating it
		newRow = dict(row)

		# Get the 'Inspected' value (defaults to False if missing)
		inspected = row.get("Inspected", False)

		# Apply row-level style
		newRow[" __style__"] = {
			"backgroundColor": "#d4edda" if inspected else "#f8d7da", # light green / red
			"color": "#155724" if inspected else "#721c24", # dark green / red text
			"fontWeight": "bold"
		}

		styledRows.append(newRow)

	return styledRows

```

---

<div class="post-metadata">

**Author:** ![Alex\_Ford-King](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Alex\_Ford-King](https://forum.inductiveautomation.com/u/Alex_Ford-King)\
**Post date:** [April 21, 2025, 4:49pm UTC](https://forum.inductiveautomation.com/t/styling-rows-only-showing-most-recent-row/105335/3 "2025-04-21T16:49:15Z")

</div>

Took you code and applied it. It no longer only shows one row but still no color change. Where is the error here?

---

<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:** [April 21, 2025, 4:51pm UTC](https://forum.inductiveautomation.com/t/styling-rows-only-showing-most-recent-row/105335/4 "2025-04-21T16:51:42Z")

</div>

Again, just taking the first thing I see:  
` __style__ ` is nothing (an LLM hallucination) - you need to return a value at the `style` key:

> **[Styling Rows Based on Values | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-display-palette/perspective-table/styling-rows)**
>
> This page includes examples detailing different ways to style rows based on values using Script Transforms. Each example accomplishes similiar results through different binding and data types to change the background color of a row or individual...
