Custom column renderer for Grid

Hello community,

I am migrating a custom implementation from table to the new grid component.

I was using the table.addGeneratedColumn feature, for generating a custom column with a Panel or a MenuBar inside.

I’m just looking to reproduce the same easily with the Grid, but i’m lost … I saw the chain with Data → Converter → Renderer, but no way to have a simple Panel renderer …
It seems to be possible with new Renderer but i’m finding so strange to have to use GWT compentnt and do the RPC links.

Is it possible to have a simple way ?

Thanks a lot

I don’t exactly know what you are doing with the Panel and MenuBar, but having Vaadin components in a rendered column sounds like there could be some trouble with that. Most of the current Vaadin components (other than Grid itself and some others) are not really designed to be used as standalone GWT widgets, so you there could be some issues with using them in that way. Normally, column renderers use normal GWT widgets or low-level DOM elements, which should be faster.

I used the column generator to dynamically display action buttons in the tbale rows.

Like that :

The “Actions” column is dynamic and in this case it was a MenuBar (previously a Panel with buttons).
The component MyTable listen events and throw custom events to the views !

I just want to reproduce that with the grid …

I too have a similar requirement. Converting from table to Grid and want to retain existing components in the table column.

I will appreciate if there is an easy way to do it.

I made some progress in this.

Server Side Renderer

[code]
public class MyWidgetRenderer extends ClickableRenderer< {

public MyWidgetRenderer ()    {
    super(MyWidget.class);
}

}
[/code]Client Side Renderer and Connector

public class VMyWidgetRenderer extends ClickableRenderer<String, VMyWidget> {

    @Override
    public VMyWidget createWidget() {
        return GWT.create(VMyWidget.class);
    }

    @Override
    public void render(RendererCellReference cell, String data, VMyWidgetwidget) {
        widget.getElement().setInnerText(data);
        widget.setText(data);
    }

}
[/code][code]
@Connect(MyWidgetRenderer .class)
public class VMyWidgetRendererConnector extends AbstractRendererConnector<String> {

    @Override
    public VMyWidgetRenderer getRenderer() {
        return (VMyWidgetRenderer) super.getRenderer();
    }
}

I am setting the widget as the cell value in datasource.

The widget is showing up in Grid.

But the value it shows is some number, some id may be widget id. The number is incremental for each row.

I was expecting that the widget would have all the attributes set as it is.

Any idea, what am I missing?

I found the problem in my implementation. the presentation type in my client side renderer (VMyWidgetRenderer) has to be the same as column type. And it has to be a client side type.

I created an intermediate class to assign values from server side class MyWidget and used that type in Renderer.
It works with that.

But that doesn’t resolve my problem. My aim was to reuse the entire logic and the server side compoenents I already have.

Currently I am adding that in a Table and it works fine. But I can’t use those with Grid.

I think I will have to extend functionality of Vaadin Table to get some features like filtering in column header.