Export Actions

ExportAction is a base list action designed for exporting data grid contents using a specified exporter. An instance of DataGridExporter is required for this action.

This action can be configured for use with both dataGrid and treeDataGrid components.

Within ExportAction, there are methods available for managing functions that extract values from DataGrid columns:

  • addColumnValueProvider() adds a function to retrieve values from a column.

  • removeColumnValueProvider() removes a column value provider function by column id.

ExportAction has three export modes: all rows, the current page, and selected rows.

export action
  • The All rows option exports all database records considering the applied filter and the initial data loader query from the view. Data loading occurs in batches, with the batch size configurable through the jmix.gridexport.exportAllBatchSize application property.

  • The Current page option exports only the content displayed on the current page of the data grid.

  • The Selected rows option export only records selected in the data grid.

The set of export options can be defined by a particular action using its setAvailableExportModes() method and corresponding availableExportModes property in XML. The default set of options is defined by the jmix.gridexport.default-export-modes application property.

You can override the header and message of the dialog by adding messages with exportConfirmationDialog.header and exportConfirmationDialog.message keys to your message bundle.

ExcelExportAction

ExcelExportAction is an action extending ExportAction and designed to export the data grid content in XLSX format.

The action is implemented by the io.jmix.gridexportflowui.action.ExcelExportAction class and should be defined in XML using type="grdexp_excelExport" action’s attribute for a list component. Common action parameters can be configured through XML attributes within the action element. For more information, refer to the Declarative Actions documentation.

For example:

<actions>
    <action id="excelExport" type="grdexp_excelExport"/>
</actions>

Alternatively, you can inject the action into the view controller and customize its settings using setter methods:

@ViewComponent("customersDataGrid.excelExport")
private ExcelExportAction customersDataGridExcelExport;

@Subscribe
public void onInit(final InitEvent event) {
    customersDataGridExcelExport.setText("Export data grid to Excel");
}

You can also override localized data format strings. The default format string settings for Excel export are as follows:

excelExporter.label=Excel
excelExporter.true=Yes
excelExporter.false=No
excelExporter.empty=[Empty]
excelExporter.bytes=<bytes>
excelExporter.timeFormat=h:mm
excelExporter.dateFormat=m/d/yy
excelExporter.dateTimeFormat=m/d/yy h:mm
excelExporter.integerFormat=#,##0
excelExporter.doubleFormat=#,##0.00##############

JsonExportAction

JsonExportAction is an action extending ExportAction and designed to export the data grid content in JSON format.

The action is implemented by the io.jmix.gridexportflowui.action.JsonExportAction class and should be defined in XML using type="grdexp_jsonExport" action’s attribute for a list component. Common action parameters can be configured through XML attributes within the action element. For more information, refer to the Declarative Actions documentation.

For example:

<actions>
    <action id="jsonExport" type="grdexp_jsonExport"/>
</actions>

Alternatively, you can inject the action into the view controller and customize its settings using setter methods:

@ViewComponent("customersDataGrid.jsonExport")
private JsonExportAction customersDataGridJsonExport;

@Subscribe
public void onInit(final InitEvent event) {
    customersDataGridJsonExport.setText("Export data grid to JSON");
}

Limitations

  • When exporting TreeDataGrid, the column containing the hierarchy property will not include any padding.

  • Exporting entities with a composite primary key is not supported.