Adding Dropdown box into PowerTable

I found how to do it it in a regular table here:

inductiveautomation.com/forum/v … umn#p24546

Does anyone know how to do this with a powertable?

Thanks!

  • Mike

Use the configureEditor extension function.

	if colName == 'englimitmode':
		return {'options': [(0, 'None'), (1, 'High'), (2, 'Low'), (3, 'Both')]}
2 Likes

Hi!

Thanks for this post, it helped me as well. However, I’m running into an odd issue when using it. I can get the dropdown list to appear in the table, but when I make a selection from the list, the cell remains blank. Do I need to add code that actually changes the value of the cell to the selected item, or should it be doing this normally? I am seeing this behavior in the designer and the staging client.

Thanks!

I figured it out. I haven’t used the Power Table much before, so I didn’t realize that it doesn’t automatically accept edits. I needed to enable the “onCellEdited” extension function. Then I used the example code written there with one small change: instead of putting newValue into the cell, I needed to put the label associated with that value in the dropdown options, so I added a little code to map the value to the label properly and put the label into the cell.

All in all, thanks for the help!

Hello, I was looking to add a way to put drop down in a Power Table and I found this topic.

I have added the given code in ‘configureEditor’ extension function but I can not get drop down to appear in the table. Am I missing something else? My column data type in ‘String’.

Thanks!

You might need to make the column with the dropdown “Editable” through the table Customizer.

1 Like

It worked. :smiley:

Thanks a lot!

Is there a way to dynamically create the returned dictionary to the ConfigureEditor? Something like
if colName = ‘Brands’:
newDict = dict((k, v) for k, v in (e.split(’ - ‘) for e in self.strBrands.split(’,’)))
return {‘options’: [newDict]}

where the dynamic property strBrands is something like “‘BrandA’-‘BrandA’,‘BrandB’-‘BrandB’…”

1 Like

Ron,
Yes, it is possible to construct the list dynamically. I modified your code slightly:

if colName == "type": brands = "'BrandA'-'BrandA','BrandB'-'BrandB'" newList = [(k, v) for k, v in (e.split('-') for e in brands.replace("'","").split(','))] return {'options': newList}

Thanks Paul.

Is there a way to reference a Dataset for the Options?

If you need dynamic flexibility, take a look at this post: