Vaadin 10 : Component Renderer not working

I followed the link https://vaadin.com/docs/v10/flow/components/tutorial-flow-grid.html for component renderer. Below is the code, suggested in above link, to show Icons. grid.addColumn(new ComponentRenderer<>( () -> new Icon(VaadinIcon.ARROW_LEFT)));
Above code is not working. Please help…

Hi,

the code in the link is working.

You have to take into account that only the main part of the code is included.

In the code below you can also see how it works:


import com.vaadin.flow.component.dependency.HtmlImport;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.data.renderer.ComponentRenderer;
import com.vaadin.flow.router.Route;

/**
 * The main view contains a button and a template element.
 */
@HtmlImport("styles/shared-styles.html")
@Route("")
public class MainView extends VerticalLayout {

    public MainView() {
        Grid<String> grid = new Grid<>();
        grid.setItems( "one","two","three");

        grid.addColumn(String::toString).setHeader("Number");

        grid.addColumn(new ComponentRenderer<>(()-> {
            return new Icon(VaadinIcon.FEMALE);
        })).setHeader("Icon");


        add(grid);
    }
}

17187508.png

Sorry…it was my mistake. It’s working now. Thank you for quick response !!!

Hi everyone. Is there some way to use it with a TreeGrid? Renderer seems to not resolve prepared custom content once I set hierarchy column.

I’ve tried the code in Vaadin 12.0.6 and Chrome and it doesn’t work. In FireFox it works.
Chrome is version 72.0.3626.109.
FireFox is version 65.0.1.

17523135.png

Luca Lezzerini:
I’ve tried the code in Vaadin 12.0.6 and Chrome and it doesn’t work. In FireFox it works.
Chrome is version 72.0.3626.109.
FireFox is version 65.0.1.

https://github.com/vaadin/platform/issues/557

Thank you very much Иванов!

Hello,

Is the fix included in 12.0.7? I’ve 72.0.3626.96 version of Chrome.
The method “grid.select(item)” is still giving the “Type error” on the latest release 12.0.7.