Grid renderer for boolean?


I am trying to render boolean column to show other values than (“true”, “false”).

I override addColumn method:

    public Column<T> addColumn(String propertyName) {

        try {

            Class<?> type = clazz.getDeclaredField(propertyName).getType();

            ValueProvider<T, ?> vProvider = getPropertySet().getProperty(propertyName).get().getGetter();

                Column c = super.addColumn(new LocalDateTimeRenderer(vProvider, "yyyy-MM-dd HH:mm"))

                return c;



        } catch (Exception e) {

        return super.addColumn(propertyName);

Depends on what you want to display instead, you did not say what you want. What I did is showing the VaadinIcons CLOSE for false and CHECK for true.

I have a partial answer for you. Partial because you cant use my exact code within your override of addColumn but only works when adding the column manually to the grid. I imagine that in order to use it in your override you’ll have to adjust and generify my code a little.

grid.addComponentColumn((item) -> {
	Icon icon;
	if(item.isReady()){ // change this to your own getter for the boolean value
		icon = VaadinIcon.CHECK.create();
	} else {
		icon = VaadinIcon.CLOSE.create();
	return icon;
		.setKey("ready") // set your own column key ;)
		.setComparator(Comparator.comparing(FooBar::isReady)); // change this to your own getter for the boolean value

its seems that i need to write my own BooleanRenderer…