diff --git a/src/extensions/export/bootstrap-table-export.js b/src/extensions/export/bootstrap-table-export.js index fae4a7d847..a850c4decd 100644 --- a/src/extensions/export/bootstrap-table-export.js +++ b/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); + } }); } }