# Table cell dropdown query

**URL:** <https://forum.inductiveautomation.com/t/table-cell-dropdown-query/14539>\
**Category:** Ignition\
**Created:** [June 16, 2017, 3:29am UTC](https://forum.inductiveautomation.com/t/table-cell-dropdown-query/14539 "2017-06-16T03:29:48Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![chasondeshotel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chasondeshotel/32/20032_2.png) [@chasondeshotel](https://forum.inductiveautomation.com/u/chasondeshotel)\
**Post date:** [March 23, 2019, 12:51am UTC](https://forum.inductiveautomation.com/t/table-cell-dropdown-query/14539/8 "2019-03-23T00:51:11Z")

</div>

I used what was above exactly, with the exception that I gave the JComboBox some items ( JComboBox(['foo','bar','baz']) )

Anyway, I guess since I'm necromancing I'll go ahead and post the solution:

If you want the JComboBox to drop down and be selectable, you have to do this in the configureEditor section, which is a bit more tricky. The cell will not look like a dropdown until you give it focus unless you configure the cell _and_ the editor. I personally think it looks nicer when the dropdown only displays on focus

> [@Dynamic drop down values in table](http://forum.inductiveautomation.com/t/dynamic-drop-down-values-in-table/12354):
>
> Create a power table with test data and paste the following into the configureEditor extension function. Make the String Column editable. [code] from javax.swing import AbstractCellEditor,JComboBox from javax.swing.table import TableCellEditor class myTableCellEditor(TableCellEditor,AbstractCellEditor): def \_\_init\_\_(self, tableComponent): self.table= tableComponent self.cbValues = None def getTableCellEditorComponent(self, table, value, isSelected, rowIndex, vColIndex): # Conten…

And since I trimmed that up a (tiny) bit, here's a JComboBox power table drop down selectyboi that does scale modes

```auto
from javax.swing import AbstractCellEditor,JComboBox
from javax.swing.table import TableCellEditor

class myTableCellEditor( TableCellEditor, AbstractCellEditor ):	

def __init__ (self, tableComponent):
	self.table = tableComponent
	self.comboBox = None
	
def getTableCellEditorComponent(self, table, value, isSelected, rowIndex, vColIndex):

	# make a box. you could do a db query here or whatever
	scaleModes = ['Off', 'Linear', 'Square Root', 'Exponential Filter', 'Bit Inversion']
	self.comboBox = JComboBox(scaleModes)

	# set the currently selected item
	initialVal = self.table.data.getValueAt( rowIndex, 'Scale Mode' )
	self.comboBox.setSelectedItem( initialVal )

	return self.comboBox
		
def getCellEditorValue(self):
	return self.comboBox.getSelectedItem()
	
if colName == 'Scale Mode':
	return {'editor' : myTableCellEditor( self ) }

```

tl;dr: I should have searched better ¯\_(ツ)\_/¯

---

_[View the full topic](https://forum.inductiveautomation.com/t/table-cell-dropdown-query/14539)._
