"addPrintable" for DataGrid?

Hello,
I required some features of the DataGrid so I exchanged a GroupTable with a DataGrid, so far everything is working besides the Excel printout action. I use the ComponentRenderer for the columns and in the GroupTable I had the method addPrintable to define the values for the Excel export. Is there a similar mechanism in the datagrid?

All I can see in the export, is the string representations of the components:
image

Hello!

Unfortunately, there is no similar functionality in the DataGrid. For now, the only way is to extend ExcelExporter class and override the createDataGridRow() method:

public class MyExcelExporter extends ExcelExporter {

    @Override
    protected void createDataGridRow(DataGrid dataGrid, List<DataGrid.Column> columns, int startColumn, int rowNumber, Object itemId) {
        super.createDataGridRow(dataGrid, columns, startColumn, rowNumber, itemId);
    }
}

And use:

@Inject
private DataGrid<Project> dataGrid;
@Inject
private ExportDisplay exportDisplay;

private MyExcelExporter myExcelExporter = new MyExcelExporter();

@Subscribe("dataGrid.excel")
public void onDataGridExcel(Action.ActionPerformedEvent event) {
    myExcelExporter.exportDataGrid(dataGrid, exportDisplay);
}
1 Like