Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Add an icon in Vaadin Grid

Abhishek Krishna
2 years ago Nov 07, 2019 3:45pm
Kaspar Scherrer
2 years ago Nov 07, 2019 4:01pm

What you're looking for is the method grid.addComponentColumn(). Inside that component renderer you can check whatever value and return a different component depending on that value.

Grid<Person> grid = new Grid<>();
grid.addComponentColumn(item -> {
	Icon icon;
		icon = VaadinIcon.CHECK_CIRCLE.create();
	} else {
		icon = VaadinIcon.CLOSE_CIRCLE.create();
	return icon;

I have exactly this setup for a boolean column (except that I don't use Person class), so I left some minor improvements like icon-color and comparator here ;)

Last updated on Nov, 7th 2019
Abhishek Krishna
2 years ago Nov 08, 2019 8:19am
Matias Gutierrez
9 months ago May 12, 2021 3:42pm