Excel export action disable selected rows option

Hi,

I am using excel export to download the content of the table in xlsx form.

Now if a record is selected and then click on download, a dialog box appears with 3 options :
selected rows, all rows and cancel.

I don’t want to show selected rows button in the dialog. Is it possible ?

Thanks in advance.

Hi Vikrant!

Thanks for your question.
To customize the dialog options, you can extend the excel export action and override the behavior.
Then, just use your action instead of excel export.

Small example:

@ActionType(MyExcelExport.ID)
public class MyExcelExport extends ExcelExportAction {

    public static final String ID = "myExcelExport";

    public MyExcelExport() {
        this(ID);
    }

    public MyExcelExport(String id) {
        this(id, null);
    }

    public MyExcelExport(String id, String shortcut) {
        super(id, shortcut);
    }

    @Override
    protected void execute() {
        if (tableExporter == null) {
            throw new IllegalStateException("Table exporter is not defined");
        }

        AbstractAction exportAllAction = new AbstractAction("ExportMode.ALL_ROWS") {
            @Override
            public void actionPerform(Component component) {
                doExport(ExportMode.ALL_ROWS);
            }
        };
        exportAllAction.setCaption(messages.getMessage(ExportMode.ALL_ROWS));
        exportAllAction.setPrimary(true);

        Dialogs dialogs = ComponentsHelper.getScreenContext(target).getDialogs();

        dialogs.createOptionDialog()
                .withCaption(getMessage("exportConfirmationDialog.caption"))
                .withMessage(getMessage("exportConfirmationDialog.message"))
                .withActions(
                        exportAllAction,
                        new DialogAction(DialogAction.Type.CANCEL)
                )
                .withWidth("530px")
                .show();
    }

    @Override
    protected String getMessage(String id) {
        return messages.getMessage(ExportAction.class, id);
    }
}

Code example for latest version Jmix Framework 1.5.0-RC1.

Regards,
Dmitriy