xdev-software / vaadin-grid-exporter

Makes it possible to export Vaadin Grids to different formats

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exporting columns that are defined by ComponentRenderer

josegulisano opened this issue · comments

I have several grid columns that have custom renderers
Column myColumn = this.addColumn(new ComponentRenderer<>(this::createUserNumber))

These columns do not get included in the export. Is there a way to configure the exporter to include these values as part of the export?

At fist: The code that extracts the data from the Grid can be found here.

Currently we support ValueProviders and simple renderers.

These are normally sufficient to extract the required data because other renderers usually very specific components (e.g. charts or buttons) that can't be printed.

I don't know what createUserNumber is doing exactly but if it's just displaying a Number as a String you can also use a Valueprovider or TextRenderer.

The other alternative that might work would be a hidden column that contains the "unrendered" value.

I was able to make it work with a "hidden" column.

The column I was having trouble with is a hyperlinked cell in the grid. I am using a ComponentRenderer to render the Anchor:

Column myColumn = this.addColumn(new ComponentRenderer<>(this::createUserNumber))

private Component createUserNumber(User user) {
        String route = RouteConfiguration.forSessionScope().getUrl(User.class, user.getId());
        Anchor anchor = new Anchor(route, userDetails.getId().toString());
            Tooltips.getCurrent().setTooltip(anchor, "View user details");
            return anchor;
}

Unless you have any other suggestions for creating the hyperlinked cell, I'll go with the hidden column option.

Thank you!