From 4d1e80353d242ea0fd851c3a1feb5ca7f69ba770 Mon Sep 17 00:00:00 2001 From: Flounn Date: Thu, 4 Aug 2016 14:02:52 +0200 Subject: [PATCH] Hide stateField before export and show after --- .../export/bootstrap-table-export.js | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/extensions/export/bootstrap-table-export.js b/src/extensions/export/bootstrap-table-export.js index 850fe4bbb7..b66ddf34bc 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); + } }); } }