Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    I cant get selectitem filter to work

    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:

    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());
        }
    }

    #2
    Hi,

    is this really the working code? extends SelectItem seems wrong to me.

    Assuming that it is a ComboBoxItem, just use setCriterionSetter. I do the same for my Zipcode field, where I can enter either zipcode or citynames by creating a or-AdvancedCriteria from the user input.

    Best regards
    Blama

    Comment


      #3
      Sorry, it's setCriterionGetter.

      Comment


        #4
        Perhaps, also a call to setCriteriaField is enough.

        Comment


          #5
          Oh, its a working example. Why do you feel that extending selectitem is wrong? Anyhow, i took two screenshots of the item "in action" to illustrate how it works when the picklist is displayed and a country is selected:

          Click image for larger version

Name:	Screen Shot 2017-06-26 at 08.26.13.png
Views:	293
Size:	82.7 KB
ID:	245206 Click image for larger version

Name:	Screen Shot 2017-06-26 at 08.26.25.png
Views:	274
Size:	10.7 KB
ID:	245207

          So, this works fine, except fore that, as mentioned, i can't type for example "i" and have the form move to Iceland.

          I will try your suggestions, thanks a lot Blama! Although i already tried setcriteriafield which didn't change anything.

          I'll update when i have tried everything.

          Comment


            #6
            Ah, OK. Now I get it. It really is a SelectItem. setCriteriaField() is related to sth else and does not apply here. Same for the setCriterionGetter(). These are related to the serach-criteria, a ComboBoxItem generates.
            You are looking for sth else ("API to configure picklist jumping in the pickList"). I don't know if that is there, but if there is not, the change will affect all the features built here.

            A different option could also be to use a ComboBoxItem, which could support searching for "ermany", "+49", "354", etc.
            This is what it looks like here:
            Click image for larger version

Name:	CountrySelect.png
Views:	151
Size:	2.9 KB
ID:	245210

            Pro: Better search
            Con: Text entry box and no flag once an entry gets selected. "(+354)" only would be possible.

            But anyway, I don't know if what you are looking for is possible as of today.

            Best regards
            Blama

            Comment

            Working...
            X