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

Empty Rows, no format choice

JariHanah opened this issue · comments

Hello, I just tested the addon,
1 I get empty rows,
2 does not read header if header contains components instead,
3 and the dialog does not ask for a format,

sample code of columns generated.

Column<BasicDate> selectedColumn = addComponentColumn((source) -> {
            BasicDate item = source;
            BasicDate result = calsSelect.getValue().getDate(item.getDate());
            return generalRenderer.renderDate(result);

        }).setWidth("10px").setFlexGrow(1).setAutoWidth(true).setHeader(getT(cal.getName())+BasicCalendar.INFO_NAME);
        selectedColumn.setKey(KEY + ++count);//.setHeader(getT(b.getName() + BasicCalendar.INFO_SHORT));
        selectedColumn.setId(KEY + count);

Using Vaadin 24.3.3
Screenshot 2024-01-18 215817
Screenshot 2024-01-18 215756
Screenshot 2024-01-18 215737

Hi,

thank you for the issue.

Regarding your points:

1 I get empty rows,

This may be the case when you use very specific renderers. We can't e.g. export components that contain blobs like images.
Currently the following is supported:

  • ValueProvider / ColumnPathRenderer
  • BasicRenderer (and everything that extends from it)

This behavior can be overridden by extending GridDataExtractor and setting the supplier here:

protected Function<Grid<T>, GridDataExtractor<T>> gridDataExtractorSupplier = GridDataExtractor::new;

2 does not read header if header contains components instead,

The code how these values are extracted can be found here:

final Optional<String> optHeaderComponentText = Optional.ofNullable(column.getHeaderComponent())
.map(Component::getElement)
.map(Element::getText);
if(optHeaderComponentText.isPresent())
{
return optHeaderComponentText;
}
return Optional.ofNullable(column.getHeaderText());

Again as stated above if you use a very special component like e.g. an image this might not work.
You can however create a custom ColumnConfigurationBuilder that e.g. additional uses ColumnConfigurationHeaderResolvingStrategyBuilder#withManualColumnHeaderStrategy or something similar, to do the header-resolving yourself.

3 and the dialog does not ask for a format,

It should do that...
What version are you using exactly and what formats did you specify?

sample code of columns generated.

Sorry but I can't quite read the code... Many important parts (what e.g. does method getT do or what is generalRenderer?) are missing and it's not very well formatted either.

Feel free to pasted the complete code here :)

Screenshots

The styling also looks wrong in the screenshots, maybe there is a problem with the Vaadin generated frontend?
Example:
grafik
should look more like this:
grafik

Closing due to lack of feedback