Vaadin 8 Grid.Column.setRenderer missing.

I see setRenderer method missing in Vaadin 8. How can the rendered be set on an existing column?

It was not possible until a while ago, see https://github.com/vaadin/framework/issues/8250. Should be possible now in 8.0.3

Thanks a lot Pontus! Lesson I learned use always the last version!

Hi,
I have a requirement of migration of vaadin7 grid to latest grid.And I have a list of renderers and in old i can set the renderer after creating column using the setRenderer() method also.But the mentioned method is missing in new …if any solution to achieve my requirement.

Saju Philip Thankachan:
Hi,
I have a requirement of migration of vaadin7 grid to latest grid.And I have a list of renderers and in old i can set the renderer after creating column using the setRenderer() method also.But the mentioned method is missing in new …if any solution to achieve my requirement.

Here is the method: https://vaadin.com/api/framework/8.9.1/com/vaadin/client/widgets/Grid.Column.html#setRenderer-com.vaadin.client.renderers.Renderer-

I made a quick test and it seems to work for me, too:

  Grid<Bean> grid = new Grid<>();
        Bean bean = new Bean();
        bean.setName("Olli");
        grid.setItems(bean);
		// start with a default TextRenderer
        Grid.Column<Bean, String> nameColumn = grid.addColumn(e -> e.getName()).setCaption("Name");
        // then update it to a ButtonRenderer
		nameColumn.setRenderer(new ButtonRenderer<>(event -> {
            Notification.show("Hello " + ((Bean) event.getItem()).getName());
        }));

Olli Tietäväinen:

Saju Philip Thankachan:
Hi,
I have a requirement of migration of vaadin7 grid to latest grid.And I have a list of renderers and in old i can set the renderer after creating column using the setRenderer() method also.But the mentioned method is missing in new …if any solution to achieve my requirement.

Here is the method: https://vaadin.com/api/framework/8.9.1/com/vaadin/client/widgets/Grid.Column.html#setRenderer-com.vaadin.client.renderers.Renderer-

I made a quick test and it seems to work for me, too:

  Grid<Bean> grid = new Grid<>();
        Bean bean = new Bean();
        bean.setName("Olli");
        grid.setItems(bean);
		// start with a default TextRenderer
        Grid.Column<Bean, String> nameColumn = grid.addColumn(e -> e.getName()).setCaption("Name");
        // then update it to a ButtonRenderer
		nameColumn.setRenderer(new ButtonRenderer<>(event -> {
            Notification.show("Hello " + ((Bean) event.getItem()).getName());
        }));

Thanks Olli for your reply,

unfortunately it is not worked for me.
I am using :vaadin-grid-pro-flow-2.0.2.jar
And tried the below code :

					Grid<Bean> grid = new Grid<>();
	                Grid.Column<Bean> nameColumn  = grid.addColumn(t -> t.getValue(""));
					but i didnt find the nameColumn.setRenderer() method

unfortunately it is not worked for me. I am using :vaadin-grid-pro-flow-2.0.2.jar And tried the below code :

Ok, that explains it. You are not using Vaadin 8, but something newer, like Vaadin 14.

In Vaadin 14 Grid and Grid Pro, there is no longer similar Renderer concept we had in Vaadin 7 and 8.

There is new concept of TemplateRenderer, and also generic ComponentRenderer.

So you need to refactor your code to use either one.