Open JariHanah opened 3 years ago
Currently the component only offers setItemLabelGenerator
which renders both.
You can get the combobox from this API:
lookupField.getComboBox()
Which gives you the access to all the methods of the Combobox (in single select) or the MultiselectComboBox (in multiple select). You can use a renderer for the combobox:
lookupField.getComboBox().setRenderer(new ComponentRenderer<>(s -> {
return new Div(VaadinIcon.ABACUS.create(), new Span(s));
}));
Which only renders the dropdown content.
The search is still done based on setItemLabelGenerator.
In your case:
lookupField.getComboBox().setItemLabelGenerator( t -> t.getName());
lookupField.getComboBox().setRenderer(new TextRenderer<>(t -> t.getName()+t.getAddress()));
But if you're searching for "Dallas" you won't find some who is living in Dallas.
When the user searches for a customer with alot of details, phone, or name, or address, the dropdown might need a specialized itemRenderer to give the user the info needed to pick the right customer,
When he selects some customers, the LookUpField should render this info selected differently, as the user only needs a name for example to be seen in the field.
The current implementation has only one ItemRenderer for both the LookupField and the DropDown list.
the API should include this for example:
I hope the issue is explained clearly, and thank you for your great work!!!