Skip to content

Commit 59790df

Browse files
prx-lmomportuga
authored andcommitted
[hotfix/4446]
- made exporterCSVFileName to optionally be a function
1 parent 64fc196 commit 59790df

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
@@ -232,6 +232,13 @@
232232
* @description The default filename to use when saving the downloaded csv.
233233
* This will only work in some browsers.
234234
* <br/>Defaults to 'download.csv'
235+
* <pre>
236+
* gridOptions.exporterCsvFilename = "rows.csv"
237+
* </pre>
238+
* <br/>Or a function returning a string:
239+
* <pre>
240+
* gridOptions.exporterCsvFilename = function(grid, rowTypes, colTypes) { return "rows" + rowTypes + ".csv" };
241+
* </pre>
235242
*/
236243
gridOptions.exporterCsvFilename = gridOptions.exporterCsvFilename ? gridOptions.exporterCsvFilename : 'download.csv';
237244
/**
@@ -831,7 +838,8 @@
831838
var exportData = self.getData(grid, rowTypes, colTypes);
832839
var csvContent = self.formatAsCsv(exportColumnHeaders, exportData, grid.options.exporterCsvColumnSeparator);
833840

834-
self.downloadFile (grid.options.exporterCsvFilename, csvContent, grid.options.exporterCsvColumnSeparator, grid.options.exporterOlderExcelCompatibility, grid.options.exporterIsExcelCompatible);
841+
var fileName = angular.isFunction(grid.options.exporterCsvFilename) ? grid.options.exporterCsvFilename(grid, rowTypes, colTypes) : grid.options.exporterCsvFilename;
842+
self.downloadFile(fileName, csvContent, grid.options.exporterCsvColumnSeparator, grid.options.exporterOlderExcelCompatibility, grid.options.exporterIsExcelCompatible);
835843
});
836844
},
837845

0 commit comments

Comments
 (0)