Smartgwt selectitem key value issue

2019-02-16 00:52发布

问题:

I have a SelectItem which I fill through a Map that has this combo is within a listgridfield, so good up there, but when I select any item in the combobox instead of get the description or value of the map puts the key in the listgridfield.

How I can do to make me set the value instead of key? now I tried to do with AddChangeHandler but has not worked.

I got the next code:

final ListGridField measureField = new ListGridField(CdmsConstants.MEASURE_ABB,    CdmsConstants.CMB_MEASURE_TITULO, 100);

final SelectItem measureComboBox = new SelectItem();
measureComboBox.setDefaultToFirstOption(false);
measureComboBox.setName(CdmsConstants.MEASURE_ABB);
measureComboBox.setTitle(CdmsConstants.CMB_MEASURE_TITULO);
measureComboBox.setDefaultValues(CdmsConstants.CMB_DEFAULT_VALUE);
measureComboBox.setType("comboBox");
measureComboBox.setVisible(true);
measureComboBox.setValueMap(result);
measureComboBox.setValidateOnExit(true);

measureField.setEditorType(measureComboBox);

In the measureComboBox When i put the variable result (that is a Map) and click to any item of the combo the value that shows into the combo box is the key of the linckedhashmap and no the value of the item... how can i make to change this?

Thanks a lot.

回答1:

If you use a datasource instead of LinkedHashMap, then you can use setValueField method of SelectItem instance. but in this case MAY you can use setValueFormatter method of your SelectItem object.



回答2:

I had the same/similar problem, my solution that can be seen here ListGrid.setEditorCustomizer in SmartGWT was to use a datasource for the SelectItem and then implemented my own CellFormatter