# Color row table

**URL:** <https://forum.inductiveautomation.com/t/color-row-table/89259>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [April 23, 2024, 6:41am UTC](https://forum.inductiveautomation.com/t/color-row-table/89259 "2024-04-23T06:41:24Z")\
**Posts on this page:** 5\
**Page:** 1

<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:** [April 23, 2024, 6:41am UTC](https://forum.inductiveautomation.com/t/color-row-table/89259/1 "2024-04-23T06:41:24Z")

</div>

Hello I'am using `results = system.alarm.queryStatus(source=["*"])` to get status alarms.  
I put all data on a power table.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/0/3019858f24999c3d57b270ff6cbe304d3b97c815.png)

I would like color row red if State = 1 and Blue if State = 0

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/5/b582604347b932d7f381672ab5e3328d01a5e0be.png)

---

<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:** [April 23, 2024, 7:10am UTC](https://forum.inductiveautomation.com/t/color-row-table/89259/2 "2024-04-23T07:10:50Z")

</div>

Coloring a row in a table has been discussed many times around here.  
In fact, I needed to do it yesterday and couldn't remember the exact format expected by the table, and I found the answer here in 3 minutes...  
Also, you're posting a screenshot of a binding that calls your own custom functions, without showing those functions. It tells us nothing.

Short story short: You'll need to use the list of dicts format instead of a dataset, and it should look something like this:

```python
[
	{
		'value': {
			'column1': value,
			'column2': value,
			'column3': value,
			...
		},
		'style': {
			'backgroundColor': 'red' if state == 1 else 'blue' if state == 0 else None
		}
	},
	...
]

```

where each dict is a row.

That said, any reason you're not using the built-in alarm status table ?

---

<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:** [April 23, 2024, 7:24am UTC](https://forum.inductiveautomation.com/t/color-row-table/89259/3 "2024-04-23T07:24:03Z")

</div>

salut @pascal.fragnoud merci.

voici ce que j'ai fait:

```python
	""
	
	pydset = system.dataset.toPyDataSet(value.getDataset())
	
	returned_rows = []
	for row in pydset:
		row_dict = {}
		if int(row['State']) ==2:
			row_dict['State'] = {'value': row['State'], 'style': {'backgroundColor': "blue"}}
			row_dict['EventTime'] = {'value': row['EventTime'], 'style': {'backgroundColor': "blue"}}
			returned_rows.append(row_dict)
		elif int(row['State']) ==0:
			row_dict['State'] = {'value': row['State'], 'style': {'backgroundColor': "green"}}
			row_dict['EventTime'] = {'value': row['EventTime'], 'style': {'backgroundColor': "green"}}
			returned_rows.append(row_dict)
			
		else:
			row_dict['State'] = row['State']
			row_dict['EventTime'] = row['EventTime']

```

I found some lines of code on forum.

---

<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:** [April 23, 2024, 7:25am UTC](https://forum.inductiveautomation.com/t/color-row-table/89259/4 "2024-04-23T07:25:28Z")

</div>

> [@pascal.fragnoud](#):
>
> Also, you're posting a screenshot of a binding that calls your own custom functions, without showing those functions. It tells us nothing.

```python
#recuperer les alarmes en temps réels
def getAlarmesStatus():
	
	results = system.alarm.queryStatus(source=["*"])
	return results

```

---

<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:** [April 23, 2024, 7:39am UTC](https://forum.inductiveautomation.com/t/color-row-table/89259/5 "2024-04-23T07:39:21Z")

</div>

Here's a prettified version:

```python
returned_rows = []
for row in pydset:
	row_dict = {
		'value': {
			'State': row['State'],
			'EventTime': row['EventTime']
		}
	}
	if row['State'] == 2:
		row_dict['style'] = {'backgroundColor': "blue"}
	elif row['State'] == 0:
		row_dict['style'] = {'backgroundColor': "green"}
	returned_rows.append(row_dict)

```

Though I'd probably try to skip all the conversions to dataset then to py dataset.
