COMBOBOX - Hide popup suggestions

Hi,

I use a vaadin combobox on my page. I want :

  • hide popup suggestions when the filter string length is under 2 characters
  • show popup suggestions when filter string length is less then 3 characters.

I tried to use the function “setPageLength(0);” but I see a empty popup :frowning:
Help me please, how can I hide popup suggestion ? a example ?


p.s : sorry, my english is so rusty :cry:

You can override
buildFilter(String, FilteringMode)
method - just return
null
if
filteringString
is shorter than 2 characters.

I tried but it’s wrong : the popup is always display (
even when filteringString is shorter than 2 characters
)
how the method “changeVariables(Object source, Map<String, Object> variables)” work ?
other ideas ?

my code

properties of my combobox :

        setFilteringMode(FilteringMode.CONTAINS);
        setItemCaptionMode(ItemCaptionMode.PROPERTY);

the method override :

    @Override
    protected Filter buildFilter(final String filterString, FilteringMode filteringMode)
    {
        if (StringUtils.length(filterString) < 2)
        {
            return null;
        }
        else
        {

            return new Filter() {

                @Override
                public boolean passesFilter(Object itemId, Item item)
                        throws UnsupportedOperationException
                {

                    // my comparaison (return true or false)
                }

                @Override
                public boolean appliesToProperty(Object propertyId)
                {
                    return true;
                }
            };
        }
    }

What do you mean by “popup suggestion”? If you don’t want to see combobox items return the filter, that returns
false
when the string length is smaller than 2.

Hi,

Thanks for you post. I attach a screenshot to see you my problem.
When my filter returns false for all suggestions, I can see a empty popup (see. screenshot)
How can I hide this popup ?
13485.jpg

You can’t - this is the combobox looks like. Probably you need a diffrent component, take a look at
ActionButtonTextfield
.