I'm working on a new application using vaadin-spring-boot-starter 21.0.7 and trying to render training database information in a Grid. I'd like to have the first column in the list be a checkbox for Active/Inactive, but I can't figure out how to get that done. Everything I've seen has been for Vaadin 7 or 8. Mostly current code is in MainView.java at https://github.com/gregoryleblanc/ealOperators/tree/vaadin
Asked
Active
Viewed 271 times
2 Answers
3
You can do it like this for Vaadin 14 and newer. I have no experience with older versions of Vaadin.
grid.addComponentColumn(myBean -> {
Checkbox checkbox = new Checkbox();
checkbox.setValue(true); // this you must handle
checkbox.addClickListener(e -> {
// todo
}
return checkbox;
});
The lambda may be replaced with a method reference
grid.addComponentColumn(this::createCheckboxComponent);
private Component createCheckboxComponent(MyBean myBean) {
Checkbox checkbox = new Checkbox();
// code here
return checkbox;
}

Avec
- 1,626
- 21
- 31
1
I'm using some super old version of vaadin, but I guess the same solution should work in the latest one as well, here's how I usually do it:
- column of type
String
- column has added
ButtonRenderer
(column.setRenderer
) renderer with event listener, that allows me to handle user's click action - value would be a String with FontAwesome font (added custom CSS style
font-family
and configured it at grid withsetCellStyleGenerator
) - when checked use value
String.valueOf((char) FontAwesome.CHECK_SQUARE_O.getCodepoint())
- when unchecked use value
String.valueOf((char) FontAwesome.SQUARE_O.getCodepoint())
There could be easier ways to do it with newer version of vaadin. However, this method should still work.

Mirek Pluta
- 7,883
- 1
- 32
- 23