Articles in this section
Category / Section

How to Change the Export File Name with the Parameter Value

Published:
Updated:

To enhance the user experience and facilitate the identification and organization of exported reports, you can customize the export file name based on parameter values. By following the steps below, you will be able to provide more meaningful and dynamic names to your exported files:

  1. Register the onRenderingCompleteand onExportItemClick methods for renderingComplete and exportItemClick events, respectively. Here’s an example code sample for this:
 $(function () {
       var reportName = '';
           $("#viewer").boldReportViewer({
               reportServiceUrl: "https://demos.boldreports.com/services/api/ReportViewer",
               reportPath: '~/Resources/docs/sales-order-detail.rdl',
               renderingComplete: onRenderingComplete,
               exportItemClick: onExportItemClick
           });
       });
  1. Add the following code sample to handle the renderingComplete event, which is triggered when the report rendering is complete:
  function onRenderingComplete(event) {	
       var parameters = event.reportParameters;
       if (parameters) {
           for (var i = 0; i < parameters.length; i++) {
               if (parameters[i].name == "SalesOrderNumber") {
                   reportName = parameters[i].values[0];
               }
           }
       }
   }
  1. Include the following code sample to handle the exportItemClick event, which is triggered when an export item is clicked:
function onExportItemClick(event) {
   if(reportName != null && reportName != '' && reportName != undefined){
   event.fileName = reportName;
   }
}
  1. Run the application and change the parameter value. When you export the report, the exported file name will be dynamically set based on the parameter value.
    image.png

You can download the sample application from here

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied