# Transform rows in a table for different style - Perspective

**URL:** <https://forum.inductiveautomation.com/t/transform-rows-in-a-table-for-different-style-perspective/48672>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [July 9, 2021, 4:44pm UTC](https://forum.inductiveautomation.com/t/transform-rows-in-a-table-for-different-style-perspective/48672 "2021-07-09T16:44:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![augusto.junior](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@augusto.junior](https://forum.inductiveautomation.com/u/augusto.junior)\
**Post date:** [July 9, 2021, 4:44pm UTC](https://forum.inductiveautomation.com/t/transform-rows-in-a-table-for-different-style-perspective/48672/1 "2021-07-09T16:44:19Z")

</div>

Hi guys,

I need to change the color for the rows in a table where my part number matches with a part number in a list.

My “else” works, but the style in my “if” does not change. And it’s weird, because I print the style on the console and I see the style in the output table. However, the same code in the Transform in Bindings does not change the style.

I appreciate any help.

```
if self.getSibling("Checkbox").props.selected == True:
	PartNumber = '84906731SH' """self.getSibling("Label_3").props.text"""
	Table = system.db.runPrepQuery("SELECT distinct B2.[ParentPart] FROM [BNDSYS02].[dbo].[BOM] B1 join [BNDSYS02].[dbo].[BOM] B2 on B1.ChildPart = B2.ChildPart inner join [Ignition].[dbo].[v_kanban] on B2.ParentPart = Part where B1.ParentPart = ? and B2.SourcePlant = 03", [PartNumber])
	output_json = []	
	list = []	
	style_red = {"backgroundColor": "#FF0000"}
	style_blue = {"color": "#FFFFFF", "backgroundColor": "#0000D9", "fontWeight": "bold"}
	
	for row in range(Table.getRowCount()):
		for col in range(Table.getColumnCount()):
			list.append( str(Table.getValueAt(row,col).replace(' ','') ))
	
	for row in range(value.getRowCount()):
		row_object = {}
		row_value = {}
		row_style = {}
		for col in range(value.getColumnCount()):    
			row_value[value.getColumnName(col)] = value.getValueAt(row, col)
		   	row_object['value'] = row_value
	   		
	   		if value.getValueAt(row, col) in list:
				row_style = style_blue		     	    
		   	row_object['style'] = row_style
		output_json.append(row_object)
	return output_json
	
else: 

	output_json = []
	
	style_red = {"backgroundColor": "#FF0000"}
	style_green = {"backgroundColor": "#00AA00", "fontWeight": "bold", "fontSize": 35}
	style_yellow = {"backgroundColor": "#FFFF00"}
	
	for row in range(value.getRowCount()):
		row_object = {}
		row_value = {}
		row_style = {}
		for col in range(value.getColumnCount()):    
			row_value[value.getColumnName(col)] = value.getValueAt(row, col)
			row_object['value'] = row_value
			
			if value.getValueAt(row, col) == value.getValueAt(0, 0):
				row_style = style_green
			row_object['style'] = row_style
		output_json.append(row_object)
	return output_json

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/4/a40e00c385fc29ba3e4a0dc48727c41d98aaf44b.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/0/a09a5f9a5b8a4f92e2e7fc051600bb7c36daf7b1.png)

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 9, 2021, 5:13pm UTC](https://forum.inductiveautomation.com/t/transform-rows-in-a-table-for-different-style-perspective/48672/2 "2021-07-09T17:13:02Z")

</div>

Unless the value returned from your Named Query changes you should not expect your table to update.

Also, you can replace

```auto
if self.getSibling("Checkbox").props.selected == True:

```

with

```auto
if self.getSibling("Checkbox").props.selected:

```

When I executed your script as part of a transform while in preview mode I see no change occurring when I click the checkbox because the data returned from the Named Query has not changed. If I change the state of the checkbox, exit preview mode, and examine the binding, it re-evaluates and then shows the changes.

Design mode, with checkbox unselected:

 ![Screen Shot 2021-07-09 at 10.20.10 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/2/e25151b0b667408e938eecf7c071aa06279366a0.png)

Preview mode, checkbox has become selected:

 ![Screen Shot 2021-07-09 at 10.20.17 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/5/b54baa5d73a764b2d4ba6bef68c2de8707e3f8d8.png)

Design mode, after the binding has been examined (which triggers a re-evaluation) and OK has been clicked:

 ![Screen Shot 2021-07-09 at 10.22.52 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/5/056f172659fa15a303e5107ce1cf6ac9c96916d2.png)  
In my local environment, the third row has no matching values between my datasets, while the other three rows do have matching values.

---

<div class="post-metadata">

**Author:** ![augusto.junior](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@augusto.junior](https://forum.inductiveautomation.com/u/augusto.junior)\
**Post date:** [July 9, 2021, 5:37pm UTC](https://forum.inductiveautomation.com/t/transform-rows-in-a-table-for-different-style-perspective/48672/3 "2021-07-09T17:37:29Z")

</div>

Thank you so much!

It works now. The value returned from Named Query changes as I change the label. I also set the polling from table to every 1 sec. It’s updating as it should.
