Skip to content

Commit 73df6eb

Browse files
committed
修复导出适配问题
1 parent 474d16d commit 73df6eb

4 files changed

Lines changed: 75 additions & 75 deletions

File tree

dist/extensions/export/bootstrap-table-export.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -91,46 +91,46 @@
9191
});
9292

9393
$menu.find('li').click(function () {
94-
var type = $(this).data('type'),
95-
doExport = function () {
96-
if (typeof require === 'function') {
97-
require(['tableexport'], function () {
98-
that.$el.tableExport($.extend({}, that.options.exportOptions, {
99-
type: type,
100-
escape: false
101-
}));
102-
});
103-
} else {
104-
throw new Error("RequireJS not found");
94+
var li = this;
95+
if (typeof require !== 'function') {
96+
throw new Error("RequireJS not found");
97+
}
98+
require(['tableexport'], function () {
99+
var type = $(li).data('type'),
100+
doExport = function () {
101+
that.$el.tableExport($.extend({}, that.options.exportOptions, {
102+
type: type,
103+
escape: false
104+
}));
105+
};
106+
107+
if (that.options.exportDataType === 'all' && that.options.pagination) {
108+
that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () {
109+
doExport();
110+
that.togglePagination();
111+
});
112+
that.togglePagination();
113+
} else if (that.options.exportDataType === 'selected') {
114+
var data = that.getData(),
115+
selectedData = that.getAllSelections();
116+
117+
// Quick fix #2220
118+
if (that.options.sidePagination === 'server') {
119+
data = {total: that.options.totalRows};
120+
data[that.options.dataField] = that.getData();
121+
122+
var Table = typeof require === 'function' ? require('table') : null;
123+
selectedData = {total: that.options.totalRows};
124+
selectedData[that.options.dataField] = Table && that.options.maintainSelected ? Table.api.selecteddata(that.$el) : that.getAllSelections();
105125
}
106-
};
107126

108-
if (that.options.exportDataType === 'all' && that.options.pagination) {
109-
that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () {
127+
that.load(selectedData);
128+
doExport();
129+
that.load(data);
130+
} else {
110131
doExport();
111-
that.togglePagination();
112-
});
113-
that.togglePagination();
114-
} else if (that.options.exportDataType === 'selected') {
115-
var data = that.getData(),
116-
selectedData = that.getAllSelections();
117-
118-
// Quick fix #2220
119-
if (that.options.sidePagination === 'server') {
120-
data = {total: that.options.totalRows};
121-
data[that.options.dataField] = that.getData();
122-
123-
var Table = typeof require === 'function' ? require('table') : null;
124-
selectedData = {total: that.options.totalRows};
125-
selectedData[that.options.dataField] = Table && that.options.maintainSelected ? Table.api.selecteddata(that.$el) : that.getAllSelections();
126132
}
127-
128-
that.load(selectedData);
129-
doExport();
130-
that.load(data);
131-
} else {
132-
doExport();
133-
}
133+
});
134134
});
135135
}
136136
}

dist/extensions/export/bootstrap-table-export.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "fastadmin-bootstraptable",
33
"description": "An extended Bootstrap table with radio, checkbox, sort, pagination, and other added features. (supports twitter bootstrap v2 and v3).",
4-
"version": "1.11.11",
4+
"version": "1.11.12",
55
"main": "./dist/bootstrap-table.js",
66
"devDependencies": {
77
"cz-conventional-changelog": "^1.1.5",

src/extensions/export/bootstrap-table-export.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -91,46 +91,46 @@
9191
});
9292

9393
$menu.find('li').click(function () {
94-
var type = $(this).data('type'),
95-
doExport = function () {
96-
if (typeof require === 'function') {
97-
require(['tableexport'], function () {
98-
that.$el.tableExport($.extend({}, that.options.exportOptions, {
99-
type: type,
100-
escape: false
101-
}));
102-
});
103-
} else {
104-
throw new Error("RequireJS not found");
94+
var li = this;
95+
if (typeof require !== 'function') {
96+
throw new Error("RequireJS not found");
97+
}
98+
require(['tableexport'], function () {
99+
var type = $(li).data('type'),
100+
doExport = function () {
101+
that.$el.tableExport($.extend({}, that.options.exportOptions, {
102+
type: type,
103+
escape: false
104+
}));
105+
};
106+
107+
if (that.options.exportDataType === 'all' && that.options.pagination) {
108+
that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () {
109+
doExport();
110+
that.togglePagination();
111+
});
112+
that.togglePagination();
113+
} else if (that.options.exportDataType === 'selected') {
114+
var data = that.getData(),
115+
selectedData = that.getAllSelections();
116+
117+
// Quick fix #2220
118+
if (that.options.sidePagination === 'server') {
119+
data = {total: that.options.totalRows};
120+
data[that.options.dataField] = that.getData();
121+
122+
var Table = typeof require === 'function' ? require('table') : null;
123+
selectedData = {total: that.options.totalRows};
124+
selectedData[that.options.dataField] = Table && that.options.maintainSelected ? Table.api.selecteddata(that.$el) : that.getAllSelections();
105125
}
106-
};
107126

108-
if (that.options.exportDataType === 'all' && that.options.pagination) {
109-
that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () {
127+
that.load(selectedData);
128+
doExport();
129+
that.load(data);
130+
} else {
110131
doExport();
111-
that.togglePagination();
112-
});
113-
that.togglePagination();
114-
} else if (that.options.exportDataType === 'selected') {
115-
var data = that.getData(),
116-
selectedData = that.getAllSelections();
117-
118-
// Quick fix #2220
119-
if (that.options.sidePagination === 'server') {
120-
data = {total: that.options.totalRows};
121-
data[that.options.dataField] = that.getData();
122-
123-
var Table = typeof require === 'function' ? require('table') : null;
124-
selectedData = {total: that.options.totalRows};
125-
selectedData[that.options.dataField] = Table && that.options.maintainSelected ? Table.api.selecteddata(that.$el) : that.getAllSelections();
126132
}
127-
128-
that.load(selectedData);
129-
doExport();
130-
that.load(data);
131-
} else {
132-
doExport();
133-
}
133+
});
134134
});
135135
}
136136
}

0 commit comments

Comments
 (0)