Hi @asantosu.ext ,
Look I have, in my case, 2 buttons and this choose the report to be run, for selected item from grid.
@Subscribe("printBtn75x35")
public void onPrintBtn75x35(ClickEvent<JmixButton> event) {
ReportOutputDocument label = reportRunner.byReportCode("Labels")
.addParam("entity", depositsDataGrid.getSelectedItems().iterator().next())
.withTemplateCode("750x350_V1")
.withOutputType(ReportOutputType.PDF)
.run();
downloader.download(label.getContent(), label.getDocumentName());
}
@Subscribe("printBtn76x50")
public void onPrintBtn76x50(ClickEvent<JmixButton> event) {
ReportOutputDocument label = reportRunner.byReportCode("Labels")
.addParam("entity", depositsDataGrid.getSelectedItems().iterator().next())
.withTemplateCode("762x508_V5")
.withOutputType(ReportOutputType.PDF)
.run();
downloader.download(label.getContent(), label.getDocumentName());
}
and in next I have one button for the Excel report:
// method to get report for Svalbard is run when button excelExportSvalBtn is clicked
@Subscribe(id = "excelExportSvalBtn", subject = "clickListener")
public void onExcelExportSvalBtnClick(final ClickEvent<JmixButton> event) {
// prepare the report in Excel output format by Report code and Template code
ReportOutputDocument svalbard = reportRunner.byReportCode("RepSval")
.addParam("duplicate", duplicatesDataGrid.getSelectedItems().iterator().next())
.withTemplateCode("Sval_V1")
.withOutputType(ReportOutputType.XLSX)
.run();
// download the report in Excel format
downloader.download(svalbard.getContent(), svalbard.getDocumentName());
}