Styling ListSelect in vaadin

2019-08-02 13:41发布

问题:

Please help to Styling ListSelect in Vaadin, Is it possible to set it up for choosing the first item at the list? Is it possible to set it up the height of the item? I need to set up the size of each items since the list will be use for touch display.

Thanks

回答1:

Is it possible to set it up the height of the item?

Kind of yes. ListSelect adapts to its font size somewhat nicely, so you could do e.g. like this in your Java code:

ListSelect select = new ListSelect();
...
select.setStyleName("my-select");

And then in your theme define different font styling, e.g.

.my-select {
    font: 300 12px "Open Sans", sans-serif;
}

Is it possible to set it up for choosing the first item at the list?

listSelect.setValue(item) or listSelect.select(item) programmatically selects the item.

If you do not know which is the first item, you could e.g. use

item = listSelect.getDataCommunicator().fetchItemsWithRange(0,1);

to get the first item