Icon won't show in boolean column

I run a query, add a boolean column called ‘Selection’, and assign it to a custom property. I have a power table bound to the custom property and I want to show the Boolean column as a built-in icon because the standard Boolean check box is too small. I use the following code in configureCell. My print statements show that everything is working and the returned attributes are correct, however it still shows the standard Boolean check box. What am I missing?

	attributes = {"background": "white"}
	if rowIndex % 2 == 0:
		attributes["background"] = "#8CF58C"
	if colName == "Selection":
		print'in colname'
		if self.data.getValueAt(rowIndex, "Selection") == True:
			print 'in true'
			attributes["iconPath"] = "Builtin/icons/24/check2.png"
			attributes["text"] = None
		else:
			attributes["text"] = None
			print 'in false'
	print attributes
	return attributes

It looks like it should show your icon on true, but the default on false. Are you not seeing that?

Even adding attributes["iconPath"] = None after the else: doesn’t change anything.

Honestly, what does this comment add?

Looks like the Boolean datatype has some override attributes for the iconPath.

Simple test for anyone reading this:
-use a new Power Table with the TestData enabled.
-add return {“iconPath” : “Builtin/icons/24/check2.png”} to the configureCell extension function.

image

1 Like

We’ll I’m not at my laptop so couldn’t check anything, relying on online user manual :man_shrugging:

Yes, can’t reproduce that with Boolean. May be use integer and only 0 and 1 ?

I tried that, but when I press the icon to change it from 1 to 0 or vice versa it just highlights the cell to where I have to physically punch in the new value and hit enter. This will not work for my situation. I guess I’m stuck with the tiny, default icon :sweat:

You could make that cell non-editable and update the DB or dataset on the doubleClick event.

1 Like

In initialize:

	from javax.swing import JLabel
	from com.inductiveautomation.ignition.client.images import PathIcon
	label = JLabel(PathIcon(self, "check2.png", 24, 24))
	self.putClientProperty("checked", label)

In configureCell:

	if colName == 'Boolean Column' and value:
		return {'renderer': self.getClientProperty("checked")}

Result:
image

5 Likes
{'renderer': javax.swing.JLabel[,-95,-22,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=8388608,maximumSize=,minimumSize=,preferredSize=,defaultIcon=com.inductiveautomation.ignition.client.images.PathIcon@4dc2a563,disabledIcon=,horizontalAlignment=CENTER,horizontalTextPosition=TRAILING,iconTextGap=4,labelFor=,text=,verticalAlignment=CENTER,verticalTextPosition=CENTER], 'background': 'white', 'text': None}

With your code it seems to work except the icon has an error. the attributes shows invalid in renderer

image

"check2.png" in my code sample should match the image path; I didn’t have the builtin icons so I just dropped one in the root level of my image management. "Builtin/icons/24/check2.png" should work on your system.

1 Like

Yep that fixed it. It still shows an error in the Designer but is perfect in the client. Isn’t there something about designers that doesn’t guarantee certain rendering properties?

If you close and re-open the window in the designer it should work - the initialize function of the power table doesn’t fire each time you enter preview mode, so the client property probably was either outdated or missing entirely.

Old post, sorry to bring it back but it shows on search results.

I wanted to share another possible solution instead of changing the renderers.
Just change the original value (i.e. change the query if it comes from a database) to be an integer 0 or 1, instead of a boolean, and then use iconPath on the return of the configureCell function. That way the Power Table won’t try to use a checkbox as a renderer and use the icon you want.