Browse Source

Hide stateField before export and show after

Flounn 9 years ago
parent
commit
4d1e80353d
1 changed files with 23 additions and 7 deletions
  1. 23 7
      src/extensions/export/bootstrap-table-export.js

+ 23 - 7
src/extensions/export/bootstrap-table-export.js

@@ -129,32 +129,48 @@
                                 that.load(data);
                             }
                         };
+                    
+                    var stateField = that.header.stateField;
 
                     if (that.options.exportDataType === 'all' && that.options.pagination) {
                         that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () {
+                            if (stateField){
+                                that.hideColumn(stateField);
+                            }
                             doExport();
                             that.togglePagination();
                         });
                         that.togglePagination();
                     } else if (that.options.exportDataType === 'selected') {
                         var data = that.getData(),
-                            selectedData = that.getAllSelections();
+                            selectedData = that.getSelections();
+                        if (!selectedData.length)
+                            return;
 
-                        // Quick fix #2220
                         if (that.options.sidePagination === 'server') {
-                            data = {total: that.options.totalRows};
-                            data[that.options.dataField] = that.getData();
-
-                            selectedData = {total: that.options.totalRows};
-                            selectedData[that.options.dataField] = that.getAllSelections();
+                            var dataServer = {total: that.options.totalRows};
+                            dataServer[that.options.dataField] = data;
+                            data = dataServer;
+                            var selectedDataServer = {total: selectedData.length};
+                            selectedDataServer[that.options.dataField] = selectedData;
+                            selectedData = selectedDataServer;
                         }
 
                         that.load(selectedData);
+                        if (stateField){
+                            that.hideColumn(stateField);
+                        }
                         doExport();
                         that.load(data);
                     } else {
+                        if (stateField){
+                            that.hideColumn(stateField);
+                        }
                         doExport();
                     }
+                    if (stateField){
+                        that.showColumn(stateField);
+                    }
                 });
             }
         }