Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Provide method for formatting DataGrid generated column value in export actions #542

Closed
Flaurite opened this issue Jun 21, 2021 · 1 comment
Assignees
Milestone

Comments

@Flaurite
Copy link
Contributor

Flaurite commented Jun 21, 2021

Description

See EN forum: topic.


Changes

ExportAction, JsonExportAction and ExcelExportAction now have a methods for adding function that get value from the column (DataGrid or Table).

Table's printable API now is deprecated.

API

  • addColumnValueProvider(String columnId, Function<TableExporter.ColumnValueContext, Object> columnValueProvider)
  • removeColumnValueProvider(String columnId)
  • Function<TableExporter.ColumnValueContext, Object> getColumnValueProvider(String columnId)

Example with ExcelExportAction

Screen descriptor:

<dataGrid id="ordersTable" ...>
    <actions>
         ...
        <action id="export" type="excelExport"/>
    </actions>
    <columns>
        <column property="number" id="number"/>
        <column property="complete" id="complete"/>
        <column property="description" id="description"/>
    </columns>
    <buttonsPanel id="buttonsPanel"
                  alwaysVisible="true">
        ...
        <button id="excelBtn" action="ordersTable.export"/>
    </buttonsPanel>
</dataGrid>

Screen controller:


@Named("ordersTable.export")
private ExcelExportAction ordersTableExport;

@Subscribe
public void onInit(InitEvent event) {
    ordersTableExport.addColumnValueProvider("number", context -> {
        Order order = context.getEntity();
        return "Order number: " + order.getNumber();
    });
}

QA

  1. Check DataGrid with ExcelExportAction and JsonExportAction;
  2. Check Table with ExcelExportAction and JsonExportAction;
@reznikova21
Copy link

Jmix version: 1.1.0-SNAPSHOT - verified

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants