Hi everybody!
I’m having a great time with the power table Configure cell editor function. It’s really great. I have been running into an issue though, that I would like to filter the data in the dropdowns of one column by the value of the row in the next column. Essentially:
Location | Subdestination
Washington DC | Dropdown of places in DC
San Francisico | Dropdown of places in San Fran
Is there any way to do this? I know the function runs once per each column, so it might be hard to do for each row…
Any ideas would be greatly appreciated!
I would also like to know if this is possible.
I’m looking for a sane solution as well!
Unfortunately, this really isn’t possible within the standard functions built into the Power Table. Because the configureEditor function is only called once, you can’t customize the options available per row.
If you did want to do this, you would basically have to:
- Add a property change event script firing on selectedRow changing.
- Create a new table editor object from scratch.
- Populate this table editor object dynamically.
Don’t know if this would work for anyone, but I have a table that I run a “system.dataset.filterColumn” script to remove one column, then do a “system.db.refresh” on the data to reload it. This forces a column change and causes the “configureEditor” to reload.
EDIT: This did not work the best for me but here is some code along the lines of what PGriffith was suggesting if you want it:
# Trigger on row or column change
if (event.propertyName == 'selectedRow' or event.propertyName == 'selecteColumn') and event.newValue > -1:
if event.propertyName == 'selectedRow':
row = event.newValue
column = event.source.selectedColumn
elif event.propertyName == 'selectedColumn':
row = event.source.selectedRow
column = event.newValue
#Get column name
columnName = event.source.data.getColumnName(column)
#Get sort criteria
projectName = system.util.getProjectName()
schedule = event.source.data.getValueAt(row,'Schedule')
phase = event.source.data.getValueAt(row,'Phase')
#Find column you want to have the combo box on
if columnName == 'Operator':
#Get the combo box component
comboBox = event.source.getViewport().getView().getCellEditor(row,column).getComponent()
#Clear old items out of it
comboBox.removeAllItems()
#Add items you want to it. I am adding two static and then iterating through an sql query here
comboBox.insertItemAt('Add New',0)
comboBox.insertItemAt('Rename',0)
operators = system.db.runPrepQuery("SELECT DISTINCT Operator FROM PAAP_TAG_ID_TRANSACTION WHERE Project_Name = ? AND SCHEDULE = ? ORDER BY Operator DESC;",[projectName,schedule])
for operator in operators:
comboBox.insertItemAt(operator['Operator'],0)
Has there been any movement on this?
This is turning out to be a very important missing feature for me. We keep doing a lot of dynamic forms where the number of fields and the options for each field are unknown. Currently, we are just handling this by hiding dropdowns and shifting things around on the screen, but we need a clear long-term solution.
Yes, this is currently possible, it always has been. You need to create a class that extends TableCellEditor, I believe. When it calls get editor, you create the dropdown component, with the options you like.
2 Likes
Kyle, could you give us some insight on how to do this.
Any help is greatly appreciated.
That’s awesome. Thank you very much.