Browse Source

Merge pull request #4426 from wenzhixin/feature/export-filename

Export fileName add function support
Dustin Utecht 6 years ago
parent
commit
5ea2227ce9
2 changed files with 14 additions and 0 deletions
  1. 10 0
      site/docs/extensions/export.md
  2. 4 0
      src/extensions/export/bootstrap-table-export.js

+ 10 - 0
site/docs/extensions/export.md

@@ -56,6 +56,16 @@ This is an important link to check out as some file types may require extra step
 
    export [options](https://github.com/hhurz/tableExport.jquery.plugin#options) of `tableExport.jquery.plugin`
 
+   `exportOptions.fileName` can be a string or a function, for example:
+
+   ```js
+   exportOptions: {
+      fileName: function () {
+         return 'exportName'
+      }
+   }
+   ```
+
 - **Default:** `{}`
 
 ## Column options

+ 4 - 0
src/extensions/export/bootstrap-table-export.js

@@ -194,6 +194,10 @@ $.BootstrapTable = class extends $.BootstrapTable {
         }
       })
 
+      if (typeof o.exportOptions.fileName === 'function') {
+        options.fileName = o.exportOptions.fileName()
+      }
+
       this.$el.tableExport($.extend({
         onAfterSaveToFile: () => {
           if (o.exportFooter) {