Has anyone had any experience getting the exportReport() method of ejReportViewer to export a report?
I have a requirement to embed the ejReportViewer in an application and to allow the user to interact with it (set filters, show/hide columns, etc.) and also to export the report to a pdf document.
I've got all this working except for the export to pdf.
Yes, I know that this can be done via the report viewer toolbar, but I have a requirement to not show the toolbar and to code the functions that we need, in order to make the embedding look more like the branding we want. According to the documentation as I understand it, the export function can be programmed (
https://help.syncfusion.com/api/js/ejreportviewer#methods:exportreport).
The code I put together to try the export is:
<div>
<div id="controls">
<button onclick="exportRep();">export</button>
</div>
<div id="reportviewer" name="reportviewer"></div>
</div>
@section Scripts{
@Scripts.Render("~/script/syncfusionreports")
<script type="text/javascript">
function exportRep() {
console.log("exportRep(): start");
var ejRep = $("#reportviewer").data("ejReportViewer");
ejRep.exportReport();
console.log("exportRep(): end");
}
function onReportExport(args)
{
console.log('onReportExport(): start');
var exportName = $(args.exportAction).find('#' + this._id + '_exportfileName');
exportName.val('DemoReport_01');
console.log('onReportExport(): end');
}
$(function () {
$("#reportviewer").ejReportViewer({
reportServiceUrl: "/api/Report",
reportPath: '62864599-1317-4767-ADE3-ADF47D5CB50C',
parameters: [@Html.Raw( Model )],
toolbarSettings: { showToolbar: false},
exportSettings: { exportOptions: ej.ReportViewer.ExportOptions.Pdf },
reportExport: "onReportExport"
});
})
</script>
}
The report is being displayed with the data passed in to it but clicking the export button, which calls the exportRep() function, just results in the start and end messages being displayed in the JavaScript console. No pdf is being generated.
What am I doing wrong?
Any help would be much appreciated.
Thanks.