On a window I have a Power Table and a Template Repeater, and inside the Template Repeater contains two buttons and a Power Table.
The Power Table inside the Template Repeater has a custom dataset property that I’m trying to use as a dropdown for one specific column.
Power table configureEditor that works.
isCellEditable isn’t turned off. Rows are for display and selecting only. The column “Procedure Name” successfully acts as a dropdown list.
ds = system.dataset.toPyDataSet(self.ProcedureData)
options = [(row["id"],row["name"]) for row in ds]
if colName == "Procedure Name":
return {"options":options}
Power table configureEditor inside Template Repeater that doesn’t work.
isCellEditable isn’t turned on, but I have logic to change that for the column “Type.” I have tried this with the column “Type” as editable, and still this doesn’t work. I’m stuck. I would like Type to have a dropdown list. The custom property on this Power Table is not empty; it contains a dataset 2C x 5R. Should I bind the custom property to the Template Repeater instead?
#isCellEditable
if colName <> "Type":
return True
else:
return False
#configureEditor
ds = system.dataset.toPyDataSet(self.select_agitation)
options = [(row["idSelect"], row["select_text"]) for row in ds]
if colName == "Type":
return {"options":options}
Also, can I not use system.util.getLogger() inside of an extension function?
In configureEditor, I’ve tried reading the dataset directly from tags, custom properties on the power table, and custom properties on the template repeater. I’m at a loss here and any help is appreciated.
From the power table inside the template repeater, I cannot print from the configureEditor function. Neither that nor system.util.getLogger() work from that location.
Figured it out finally. Not sure if another setting in my Power Table is causing an issue when used in a Template repeater, but this worked for me. In case anyone else has the same issue:
Doesn't work on a power table in a template repeater
#configureEditor
target = system.tag.read('[Client]Config/select_agitation').value
ds = system.dataset.toPyDataSet(target)
options = [(row["idSelect"], row["select_text"]) for row in ds]
if colName == "Type":
return {"options":options}
Works on a power table in a template repeater
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 = []
# get the available options for agitation type column from client tag.
target = system.tag.read('[Client]Config/select_agitation').value
pyData = system.dataset.toPyDataSet(target)
for row in pyData:
# append second column (select_text)
data.append(row[1])
comp.setModel(DefaultComboBoxModel(data))
return comp
return {'editor': CustomCellEditor(JComboBox())}