Disable item in Select component

I have a Select component with a few items in it. I want to disable the selection of certain items. The Book of Vaadin describes how to do this for an OptionGroup. Is there a similar way to do this for a regular “Select” component (or some other component with a drop-down list).


Did you try selectField.select(null)?

It’s not possible with the regular Select or ComboBox at least.

There could be an add-on that supports that.

I suppose you could get roughly the same behaviour with other components, such as a ListSelect or Table that expands when you put focus in a TextField. You could use the Overlay add-on or perhaps an AbsoluteLayout to position the popup, or use PopupView if you don’t need the TextField part.

Unfortunately there is nothing out of the box for that. You will have to change the components client side to include this behavior. Another not as elegant solution (that I haven’t tried out) might be to add an icon to the the disabled items, then use CSS to hide the icon and theme those elements to look the way you want them. The items would still be clickable and you would have to ignore those items in your selection listeners. Obviously this is not an optimal solution but it would allow you to not have to do client side changes to the component and depending on what you’re trying to do, this might be enough.