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 columnid
.
ExportAction
has three export modes: all rows, the current page, and selected rows.
-
The All rows option exports all records from the database taking into account applied filter and initial data loader query from the screen. Loading is performed using batches. The batch size may be configured using the jmix.gridexport.exportAllBatchSize application property.
-
The Current page option outputs only content of the current table’s page.
You can override the title and message of the dialog by adding messages with actions.exportSelectedTitle
and actions.exportSelectedCaption
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. You can configure common action parameters using XML attributes of the action
element. See Declarative Actions for details.
For example:
<actions>
<action id="excelExport" type="grdexp_excelExport"/>
</actions>
Alternatively, you can inject the action into the view controller and configure it using setters:
@ViewComponent("customersDataGrid.excelExport")
private ExcelExportAction customersDataGridExcelExport;
@Subscribe
public void onInit(final InitEvent event) {
customersDataGridExcelExport.setText("Export data grid to Excel");
}
You can override localized data format strings. The default set of format strings, defined for the excel export, is the following:
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##############
The XLS format implies the limitation for 65536 table rows. If an exported data grid contains more than 65536 rows, its content will be cut by the last row, and you will see the corresponding warning message. |
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. You can configure common action parameters using XML attributes of the action
element. See Declarative Actions for details.
For example:
<actions>
<action id="jsonExport" type="grdexp_jsonExport"/>
</actions>
Alternatively, you can inject the action into the view controller and configure it using setters:
@ViewComponent("customersDataGrid.jsonExport")
private JsonExportAction customersDataGridJsonExport;
@Subscribe
public void onInit(final InitEvent event) {
customersDataGridJsonExport.setText("Export data grid to JSON");
}