Skip to content

Commit 0e58afb

Browse files
prx-lmomportuga
authored andcommitted
[hotfix/4446]
- made exporterPdfFileName to optionally be a function
1 parent 59790df commit 0e58afb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/exporter/src/js/exporter.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@
247247
* @propertyOf ui.grid.exporter.api:GridOptions
248248
* @description The default filename to use when saving the downloaded pdf, only used in IE (other browsers open pdfs in a new window)
249249
* <br/>Defaults to 'download.pdf'
250+
* <pre>
251+
* gridOptions.exporterPdfFilename = "rows.pdf"
252+
* </pre>
253+
* <br/>Or a function returning a string:
254+
* <pre>
255+
* gridOptions.exporterPdfFilename = function(grid, rowTypes, colTypes) { return "rows" + rowTypes + ".pdf" };
256+
* </pre>
250257
*/
251258
gridOptions.exporterPdfFilename = gridOptions.exporterPdfFilename ? gridOptions.exporterPdfFilename : 'download.pdf';
252259
/**
@@ -1276,7 +1283,8 @@
12761283
docDefinition = self.prepareAsPdf(grid, exportColumnHeaders, exportData);
12771284

12781285
if (self.isIE() || navigator.appVersion.indexOf('Edge') !== -1) {
1279-
self.downloadPDF(grid.options.exporterPdfFilename, docDefinition);
1286+
var fileName = angular.isFunction(grid.options.exporterPdfFilename) ? grid.options.exporterPdfFilename(grid, rowTypes, colTypes) : grid.options.exporterPdfFilename;
1287+
self.downloadPDF(fileName, docDefinition);
12801288
} else {
12811289
pdfMake.createPdf(docDefinition).open();
12821290
}

0 commit comments

Comments
 (0)