# Power Table row select Color then change row color?

**URL:** <https://forum.inductiveautomation.com/t/power-table-row-select-color-then-change-row-color/102409>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [February 17, 2025, 4:26am UTC](https://forum.inductiveautomation.com/t/power-table-row-select-color-then-change-row-color/102409 "2025-02-17T04:26:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [February 17, 2025, 4:26am UTC](https://forum.inductiveautomation.com/t/power-table-row-select-color-then-change-row-color/102409/1 "2025-02-17T04:26:24Z")

</div>

In Power Table ,I want to double click row , then show chooseColor, users can choose one color ,Finally the table row can change color.

```python
def onDoubleClick(self, rowIndex, colIndex, colName, value, event):
 
	# 获取双击行的索引
	row_index = rowIndex
	col_index = colIndex
	
	# 可以根据需要获取当前行的背景颜色作为初始颜色
	# 这里简单假设当前行背景颜色属性可直接获取
	color_background=self.background

# current_row_color = self.rowIndex.getProperty(color_background)
	print(color_background)

	# 弹出颜色选择对话框，使用当前行背景颜色作为初始颜色，并设置自定义标题
	selected_color = system.gui.chooseColor(color_background, u"请选择行背景颜色")
	
	if selected_color is not None:
		# 设置指定行的背景颜色为用户选择的颜色
# self.selectionBackground=selected_color
		self.setProperty('rows[' + str(row_index) + '].background', selected_color)

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/3651a1ae24699e24eb1db2e826e1d4e7219389ff.png)  
But self.setProperty('rows[' + str(row\_index) + '].background', selected\_color), ERROR

```python
 Vision.Components.AdvancedTable - Error invoking extension method.
org.python.core.PyException: TypeError: 'java.awt.Color' object is not callable

```

How do I correct it?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/1/d1f5610f6d2e02f78a412a71ebf7a758953ab646.png)

---

<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:** [February 18, 2025, 3:51pm UTC](https://forum.inductiveautomation.com/t/power-table-row-select-color-then-change-row-color/102409/2 "2025-02-18T15:51:43Z")

</div>

> [@taohongyu88](#):
>
> `self.setProperty(`

There is no such method.

You cannot trust large language models/AI with Ignition scripting, because the domain is too small for them to have useful context. They will readily hallucinate functions and attributes that simply don't exist in Ignition.

I would recommend adding a dataset type custom property to the table. Put the row index as the first column, and a color value as the second column.

Then in `configureCell`, you will need to look up the current row index in that dataset and retrieve the value from it to use as a row background (if present).

---

<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:** [February 22, 2025, 12:42am UTC](https://forum.inductiveautomation.com/t/power-table-row-select-color-then-change-row-color/102409/3 "2025-02-22T00:42:06Z")

</div>

How is the table being populated? If possible, simply add a hidden string column to store the color information.

**Example:**  
Add a column to the table called 'rowColors' and use the table customizer to hide the column:  
Then, program the `onDoubleClick` extension funcion in this way:

```python
#def onDoubleClick(self, [...], event):
	# 弹出颜色选择对话框，使用当前行背景颜色作为初始颜色，并设置自定义标题
	selected_color = system.gui.chooseColor(self.background, u"请选择行背景颜色")

	if selected_color is not None:
	
		# Convert the integer parameters of the selected color to a comma delimited string
		rgbaString = '{},{},{},{}'.format(selected_color.red, selected_color.green, selected_color.blue, selected_color.alpha)
		
		# Store the string value in the hidden 'colors' column
		self.data = system.dataset.setValue(self.data, rowIndex, 'rowColors', rgbaString)

```

Finally, program the `configureCell` extension function to retrieve and utilize the colors:

```python
def configureCell(self, value, textValue, selected, rowIndex, colIndex, colName, rowView, colView):

	# Get the double click use selected color for the row from the hidden column
	storedColor = self.data.getValueAt(rowIndex, 'rowColors')
	
	# Optional:
	# Ignore the stored color parameter if it's the selected row
	# ...and simply apply the selected row color
#	if selected:
# return {'background': self.selectionBackground}
	
	# If a user selected color has been stored in the table
	if storedColor:
		# unpack the red, green, blue, alpha integer values from the stored string
		r, g, b, a = [int(value) for value in storedColor.split(',')]
		
		# Paint the cell with the user selected color
		return {'background': system.gui.color(r, g, b, a)}
	
	# Otherwise return the default value for the table
	else:
		return {'background': self.background}

```

**Result:**  
 ![Demo](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/9/692dbb884d0188c99728fd8e092af0197befed05.gif)

---

<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:** [February 24, 2025, 5:46pm UTC](https://forum.inductiveautomation.com/t/power-table-row-select-color-then-change-row-color/102409/4 "2025-02-24T17:46:34Z")

</div>

> [@justinedwards.jle](#):
>
> hidden string column

If you're going this route, just store a `java.awt.Color` directly - they're safe to serialize in datasets and you won't pay the parsing penalty every time you interact with the column.
