# Force configure cell update in power table

**URL:** <https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [December 14, 2017, 2:04am UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318 "2017-12-14T02:04:25Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [December 14, 2017, 2:04am UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/1 "2017-12-14T02:04:25Z")

</div>

I have setup a couple of dropdowns in a power table. The data is fed through an SQL query.

The first time I ran the query after writing the code for the dropdowns, everything was as it should have been. All of the dropdown options were visible.

However, the nature of the app required that users be able to edit these dropdown lists. The dropdown lists are derived from datasets, which users edit in a popup window.

When an item is added or deleted from one of these datasets, the drop down in the power table does not update for a long time. The table does eventually update, but I need it to happen immediately.

Is there perhaps a different approach to this problem?

Is there a way I can force the configureCell method to run?

---

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [December 14, 2017, 1:29pm UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/2 "2017-12-14T13:29:25Z")

</div>

Hacky Solution Found in A Previous Post: [Power Table Drop Down List with ability to enter new text?](http://forum.inductiveautomation.com/t/power-table-drop-down-list-with-ability-to-enter-new-text/12876/3)

As the person who came up this solution mentioned, this is not good solution. It puts a lot of strain on the user’s computer when they are making many edits.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [December 14, 2017, 10:23pm UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/3 "2017-12-14T22:23:49Z")

</div>

That is a horrible solution, no offense. The only way I can see, to update the editors, is to “update” the extension functions at run time. Try this, where c is a reference to the table:

```auto
c.setExtensionFunctions(c.getExtensionFunctions())

```

This should work.

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [December 14, 2017, 10:42pm UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/4 "2017-12-14T22:42:48Z")

</div>

Maybe I’m misunderstanding the problem but it seems like you could create 2 datasets as custom properties on your root container.

Whenever the user changes the items in the popup, you just refresh the datasets.

Then in you configureEditor event, you could read the values in the appropriate dataset and return those items as options.

---

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [December 14, 2017, 10:58pm UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/5 "2017-12-14T22:58:31Z")

</div>

I currently store the datasets in tags  
The user edits the datasets in the tags.  
The table feeds off those datasets to create the dropdowns.  
Unfortunately, the table lazily updates the dropdowns in the table.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [December 15, 2017, 12:06am UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/6 "2017-12-15T00:06:02Z")

</div>

By default, the columns only update when the columns themselves change, or on component start up. If you use my code posted in my last comment, it should re-fire the configureEditor function.

---

<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:** [December 15, 2017, 12:26am UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/7 "2017-12-15T00:26:20Z")

</div>

The much more efficient solution is to embed a custom editor, which will lookup the datasets dynamically whenever it’s appropriate. I’ve got a very simple example of this below; the project has an editable ‘Options’ dataset, and the available options in column B in the editable table will be dynamic based on the value in column A.

The relevant code is here:

```auto
		root = self
		from javax.swing import JComboBox, DefaultCellEditor, DefaultComboBoxModel
		
		class CustomCellEditor(DefaultCellEditor):
			def getTableCellEditorComponent(self, table, value, isSelected, row, column):
				comp = DefaultCellEditor.getTableCellEditorComponent(self, table, value, isSelected, row, column)
				data = []
				target = root.parent.getComponent("Options")
				for r in range(target.data.rowCount):
					if target.data.getValueAt(r, 0) == root.data.getValueAt(row, 0):
						data = target.data.getValueAt(r, 1).split(",")
				comp.setModel(DefaultComboBoxModel(data))
				return comp
		return {'editor': CustomCellEditor(JComboBox())}

```

Specifically, `comp.setModel(DefaultComboBoxModel(data))` - every time the table asks the editor what renderer it should use, the `CustomCellEditor` will fire `getTableCellEditorComponent` and refresh the data in the dropdown.

[Custom Editor.proj](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/40a9785686270d7a1edf294e01dcbfc64cbd56a5.proj) (9.2 KB)

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/9/9077be1a7042317830f8bfbe28ced855f3524f1d.gif)

---

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [February 5, 2018, 5:28am UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/8 "2018-02-05T05:28:15Z")

</div>

This would work, but the problem is that it is inefficient. Creating a combobox everytime a cell loads makes everything slug along. It is more efficient to create the combobox once and then reuse it.

---

<div class="post-metadata">

**Author:** ![jshannon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jshannon/32/81937_2.png) [@jshannon](https://forum.inductiveautomation.com/u/jshannon)\
**Post date:** [July 10, 2018, 3:37pm UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/9 "2018-07-10T15:37:47Z")

</div>

Awesome Paul, Thanks.  
Let me ask you this though.  
How about changing the font size of the combo box drop down list items?  
Would be easier to select on touch screens.

---

<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:** [July 10, 2018, 3:48pm UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/10 "2018-07-10T15:48:37Z")

</div>

> [@jshannon](#):
>
> How about changing the font size of the combo box drop down list items?

Within `getTableCellEditorComponent`, `comp` is a standard JComboBox; to change the item rendering you would need to subclass JComboBox's `getListCellRendererComponent` in a similar manner, and use that modified combobox in the CustomCellEditor constructor.

---

<div class="post-metadata">

**Author:** ![jshannon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jshannon/32/81937_2.png) [@jshannon](https://forum.inductiveautomation.com/u/jshannon)\
**Post date:** [July 10, 2018, 4:03pm UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/11 "2018-07-10T16:03:38Z")

</div>

Awesome Paul.

You wouldn’t happen to have an example of that would you?

---

<div class="post-metadata">

**Author:** ![jshannon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jshannon/32/81937_2.png) [@jshannon](https://forum.inductiveautomation.com/u/jshannon)\
**Post date:** [August 8, 2018, 6:05pm UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/12 "2018-08-08T18:05:55Z")

</div>

Paul, would you happen to have an example or know of one.

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [August 27, 2019, 10:56pm UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/13 "2019-08-27T22:56:04Z")

</div>

Thank you for your response. I was unable to import the linked .proj but I have been attempting variations of your example above.  
I made a Custom property for my Power Table labeled roleList.  
Property type is Dataset.  
It is running a SELECT Query.

```
SELECT '%' AS Value, ""
UNION
FROM brewshift
WHERE role != ""
ORDER BY Value ASC

```

Here is my Dataset from Query -  
 ![Power%20Table%20Drop%20Down%20List2](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/10025b8004bff6b5c60076a798f9061ac186e074.png)

I feel like I came closest to achieving my goal by placing the script below in the Component Scripting configureEditor

```
if colName == 'role':
return {'options': [self.roleList)]}

```

![Power%20Table%20Drop%20Down%20List3](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/4f34f75bf4bdf3a5ac2d199b0382e4ae4952b8eb.png)

I tried and tried to get results using Custom Method script and had no luck.  
Please advise.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 28, 2019, 12:11am UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/14 "2019-08-28T00:11:34Z")

</div>

A bit late, but for posterity, see this post, specifically this line:  
`component.setFont(component.getFont() if itemEnabled else component.getFont().deriveFont(Font.ITALIC))`

> [@Dropdown List (PMIComboBox): Disable item from selection](http://forum.inductiveautomation.com/t/dropdown-list-pmicombobox-disable-item-from-selection/23697/3):
>
> [image] [image] So I’ve worked it out with help from these two posts: (1) [swing - Java: Make one item of a jcombobox unselectable(like for a sub-caption) and edit font of that item - Stack Overflow](https://stackoverflow.com/questions/28344126/java-make-one-item-of-a-jcombobox-unselectablelike-for-a-sub-caption-and-edit/28344521#28344521) (2) [Anyway to make drop down table bigger for touchscreen projects? - #5 by PGriffith](http://forum.inductiveautomation.com/t/anyway-to-make-drop-down-table-bigger-for-touchscreen-projects/15045/5) Nothing like hacking until you get it! PS. I’ve kept the code in there to also be able to increase the height of the items by setting the ‘scale’ property. This scales the item height by the scale value (1 = no…

---

<div class="post-metadata">

**Author:** ![jshannon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jshannon/32/81937_2.png) [@jshannon](https://forum.inductiveautomation.com/u/jshannon)\
**Post date:** [August 28, 2019, 1:46pm UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/15 "2019-08-28T13:46:54Z")

</div>

Fantastic Nick. I’ll give it a go

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [August 28, 2019, 8:27pm UTC](https://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/16 "2019-08-28T20:27:05Z")

</div>

This article helped me accomplish our goal using Power Table Drop Down List.

[http://forum.inductiveautomation.com/t/power-table-drop-down-list-with-ability-to-enter-new-text/12876](http://forum.inductiveautomation.com/t/power-table-drop-down-list-with-ability-to-enter-new-text/12876)
