Reputation: 363
Using Java and GWT, I have a contentGrid with a custom column definition and a content Store.
One of the columns of the grid needs to show a combo box with several options. The combo box and its contents are defined as such:
ComboBox comboBox = new ComboBox();
SimpleStore comboBoxStore = new SimpleStore( new String[]{"text","id"}, new String[][] { new String[] {"John", "Mike"} , new String[] {"1","2"} } );
comboBoxStore.load();
comboBox.setDisplayField( "text" );
comboBox.setValueField("id" );
comboBox.setStore( comboBoxStore );
comboBox.setForceSelection( true );
comboBox.setEditable( false );
nameColumnConfig.setEditor(new GridEditor( comboBox ));
The grid then displays correctly, double-clicking the nameColumnConfig displays the combo box with the correct elements "John" and "Mike".
But when I click on one of those options and click away for the grid so it "updates" itself, the combobox displays the id of the selected option and not it's displayField.
I've been looking for a solution for some time, and I haven't found anything that could remotely let me know how to solve it or what's the cause.
I would greatly appreciate any help or insight in this issue.
Thanks.
Upvotes: 1
Views: 6070
Reputation: 11
Instead of putting like this---
comboBox.setDisplayField( "text" );
comboBox.setValueField("id" );
You have to do like
comboBox.setDisplayField( "text" );
comboBox.setValueField("text" );
sure , you will get an answer.
Upvotes: 1