Browse Source

Support data-export-types attribute.

zhixin 11 years ago
parent
commit
8b4ef7881c
1 changed files with 12 additions and 2 deletions
  1. 12 2
      src/extensions/export/bootstrap-table-export.js

+ 12 - 2
src/extensions/export/bootstrap-table-export.js

@@ -48,8 +48,18 @@
                         '</ul>',
                     '</div>'].join('')).appendTo($btnGroup);
 
-                var $menu = $export.find('.dropdown-menu');
-                $.each(this.options.exportTypes, function (i, type) {
+                var $menu = $export.find('.dropdown-menu'),
+                    exportTypes = this.options.exportTypes;
+
+                if (typeof this.options.exportTypes === 'string') {
+                    var types = this.options.exportTypes.slice(1, -1).replace(/ /g, '').split(',');
+
+                    exportTypes = [];
+                    $.each(types, function (i, value) {
+                        exportTypes.push(value.slice(1, -1));
+                    });
+                }
+                $.each(exportTypes, function (i, type) {
                     if (TYPE_NAME.hasOwnProperty(type)) {
                         $menu.append(['<li data-type="' + type + '">',
                                 '<a href="javascript:void(0)">',