vendor/assets/javascripts/extensions/bootstrap-table-export.js in bootstrap-table-rails-1.11.1.1 vs vendor/assets/javascripts/extensions/bootstrap-table-export.js in bootstrap-table-rails-1.12.1
- old
+ new
@@ -42,11 +42,11 @@
var BootstrapTable = $.fn.bootstrapTable.Constructor,
_initToolbar = BootstrapTable.prototype.initToolbar;
BootstrapTable.prototype.initToolbar = function () {
- this.showToolbar = this.options.showExport;
+ this.showToolbar = this.showToolbar || this.options.showExport;
_initToolbar.apply(this, Array.prototype.slice.apply(arguments));
if (this.options.showExport) {
var that = this,
@@ -91,39 +91,87 @@
});
$menu.find('li').click(function () {
var type = $(this).data('type'),
doExport = function () {
+
+ if (!!that.options.exportFooter) {
+ var data = that.getData();
+ var $footerRow = that.$tableFooter.find("tr").first();
+
+ var footerData = { };
+ var footerHtml = [];
+
+ $.each($footerRow.children(), function (index, footerCell) {
+
+ var footerCellHtml = $(footerCell).children(".th-inner").first().html();
+ footerData[that.columns[index].field] = footerCellHtml == ' ' ? null : footerCellHtml;
+
+ // grab footer cell text into cell index-based array
+ footerHtml.push(footerCellHtml);
+ });
+
+ that.append(footerData);
+
+ var $lastTableRow = that.$body.children().last();
+
+ $.each($lastTableRow.children(), function (index, lastTableRowCell) {
+
+ $(lastTableRowCell).html(footerHtml[index]);
+ });
+ }
+
that.$el.tableExport($.extend({}, that.options.exportOptions, {
type: type,
escape: false
}));
+
+ if (!!that.options.exportFooter) {
+ 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);
}
});
}
}
};