PDA

View Full Version : ComboBoxes empty



darkling235
4 Mar 2011, 9:33 AM
I'm working with a combobox in an editor grid. I'm attempting to build the list of options from the server and provide them to the user, but the combo box is empty, even after I watch the code place several items inside of it.



final SimpleComboBox<String> instancesCombo = new SimpleComboBox<String>();
instancesCombo.setTriggerAction(TriggerAction.ALL);
ColumnConfig column = new ColumnConfig();
column.setId("instance");
column.setHeader("Database Instance");
column.setWidth(150);
column.setEditor(new SimpleComboBoxCellEditor<String>(instancesCombo));
column.setRenderer(addrRenderer);


instancesCombo.removeAll();

List<String> instanceTables = new ArrayList<String>();

instanceTables.add(getData().getMainInstance().getAddress()
+ ":" + getData().getMainInstance().getPort() + "/"
+ getData().getMainInstance().getName());

for (InstanceData instance : getData().getInstances()) {
instanceTables.add(instance.getAddress() + ":"
+ instance.getPort() + "/" + instance.getName());
}

instancesCombo.add(instanceTables);





Can anyone point out what I'm doing wrong?
Thanks

darkling235
8 Mar 2011, 7:15 AM
Let me elaborate:
I'm creating a combobox and placing it inside a grid as a field but the values don't seem to be present unless I add them all BEFORE the grid is created. It seems like after the grid is created when I do a removeAll/add operation, its not reflected in the grid. Has anyone experience this before?
Thanks

daddieke
8 Mar 2011, 7:36 AM
I have a similar scenario. Values appearing in my ComboBoxes can be modified, added or removed by the users. To reflect these changes I work on the ListStore and that works well for me. You might try to use instancesCombo.getStore() to add or remove items.

margozzi
8 Mar 2011, 11:51 AM
My 'combo' is empty as well. i have it as an item in a 'tbar'.
I thought it was supposed to display the first item. Even when I
click on the trigger, the choices don't appear the first time, I
have to click again just to see the choices.


{
xtype: 'combo',
fieldLabel: 'Select',
labelWidth: 45,
width: 150,
autoSelect: true,
forceSelection: true,
triggerAction: 'all',
store: new Ext.data.ArrayStore({
fields: [
'value',
'displayText'
],
data: [['CpuStats', 'All CPUs'], ['CpuAverageStats', 'Averaged']]
}),
valueField: 'value',
displayField: 'displayText'
}