jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
692 stars 124 forks source link

Excel export action should take into account grid columns visibility jmix-framework/jmix#3263 #3668

Closed KremnevDmitry closed 2 months ago

KremnevDmitry commented 2 months ago

See: #3263 A migration issue for the Studio will be created after the merging. The migration should add an application to preserve the old export behavior.

jmix.gridexport.default-columns-to-export=ALL_COLUMNS

UPD: Studio issue: JST-5316


Added three options for export column filtering:

Predefined column filter predicate (enumeration)

    /**
     * Export all columns.
     */
    ALL_COLUMNS(column -> true),

    /**
     * Export only visible columns.
     */
    VISIBLE_COLUMNS(Grid.Column::isVisible);

You can set filtering options using jmix.gridexport.default-columns-to-export application property or using a properteis in the Component Inspector. The default value for new projects: VISIBLE_COLUMNS Migration will add the old value to the application.properties.

This filtering option has the lowest priority.

Flexible filtering predicate (install point)

    @Install(to = "usersDataGrid.excelExport", subject = "columnsExportFilter")
    private boolean usersDataGridExcelExportColumnsExportFilter(final Grid.Column<User> column) {
        // username and timeZone
        return column.getKey().contains("name") || column.getKey().contains("Zone");
    }

Provides the same functionality as enumeration above.

This filtering options has the secondary priority.

Specefying keys of columns for filtering (list of keys)

Using the Component Inspector, you can specify column keys to export.

                <action id="excelExport" type="grdexp_excelExport">
                    <properties>
                        <property name="columnKeysToExport" value="username, firstName, lastName"/>
                    </properties>
                </action>

This filtering option has the primary priority.