问题
I have implemented a poor-mans-searchbox using a combobox. The search expression is typed into the textfield and the user press enter. Then the search expression is added to the combo model, this is caught in the eventhandler which then runs the search, empties the combo list and populates it with the searchresults instead. However, the user then need to open the combo list manually (by pressing the little down-arrow) to see the result. It'd be nice to open the list automatically, but I haven't found out how to do that. Does anyone know?
Also the search should be performed each time the user presses a key, and not only after enter is pressed.
回答1:
Not as the poor man's solution, but you may extend the client side to do that. Tipically, the client side widget would have some method like "openResultsBox" or something similar. You could call that to open up the box. Vaadin 7 also allows you to write extensions which basically lets you extend the client side for exactly doing the very same slight changes. I am not sure why you have chosen the combobox for that though.
回答2:
the vaadin-combo-box component offers a method called "open" so simply call
reference-to-element.open();
Should do the trick.
Relevant official docs here: https://www.webcomponents.org/element/vaadin/vaadin-combo-box/elements/vaadin-combo-box#method-open
来源:https://stackoverflow.com/questions/23672032/how-to-open-a-vaadin-combobox-programmatically