Hello again,
i have finally gotten my combobox showing icon - countryname and phone prefix to work. This is done with a local datasource, and by having the "code" as displayfield, and a custom picklist with name.
The only outstanding issue i now have is that since i use "code" as displayfield, i cant get the keyboard filtering to work, i.e. i would like for Germany to be selected when the user presses G, but since the displayfield is "49", it does not work.
I think that the problem lies in that i have the "code" as displayfield, but want to show the "name" field in the picklist. But there seems not to be any way to tell the picklist to use the "name" field for the filter.
Here is my combobox class code, happy to provide all code if it makes it easier:
i have finally gotten my combobox showing icon - countryname and phone prefix to work. This is done with a local datasource, and by having the "code" as displayfield, and a custom picklist with name.
The only outstanding issue i now have is that since i use "code" as displayfield, i cant get the keyboard filtering to work, i.e. i would like for Germany to be selected when the user presses G, but since the displayfield is "49", it does not work.
I think that the problem lies in that i have the "code" as displayfield, but want to show the "name" field in the picklist. But there seems not to be any way to tell the picklist to use the "name" field for the filter.
Here is my combobox class code, happy to provide all code if it makes it easier:
Code:
public class CountryCombobox extends SelectItem { public CountryCombobox() { setImageURLPrefix("flags-2/"); setImageURLSuffix(".png"); setValueIcons(CountryConstants.getIconMap()); setAlign(Alignment.LEFT); setIconVAlign(VerticalAlignment.CENTER); //setValueMap(CountryConstants.getCountryMap()); setDefaultToFirstOption(true); setValueIconWidth(14); setValueIconHeight(14); setShowTitle(false); setCanEdit(true); setAddUnknownValues(false); setCanSelectText(false); //setShowValueIconOnly(true); setShowFocusedIcons(true); setShowFocused(true); setShowPickerIcon(false); setCanFocus(false); setSelectOnFocus(false); setWidth(60); setAutoFetchData(true); setOptionDataSource(CountryDatasource.getInstance()); setValueField("id"); setDisplayField("code");//WORKS IF I SET IT TO NAME, BUT I WANT CODE TO BE DISPLAYED WHEN THE USER HAS SELECTED ListGridField countryCodeField = new ListGridField("id", "Flag"); countryCodeField.setShowTitle(false); countryCodeField.setAlign(Alignment.CENTER); countryCodeField.setType(ListGridFieldType.IMAGE); countryCodeField.setImageHeight(15); countryCodeField.setImageWidth(15); ListGridField nameField = new ListGridField("name", null); nameField.setShowTitle(false); setPickListFields(countryCodeField, nameField); setPickListHeaderHeight(0); setPickListWidth(150); setPickListHeight(150); } public void setCountryFromMsisdn(String msisdn){ setValue(CountryEnum.fromMsisdn(msisdn).getIso()); } }
Comment