|
|
@@ -4,7 +4,7 @@
|
|
|
* https://github.com/wenzhixin/bootstrap-table/
|
|
|
*/
|
|
|
|
|
|
-!function ($) {
|
|
|
+! function ($) {
|
|
|
'use strict';
|
|
|
|
|
|
// TOOLS DEFINITION
|
|
|
@@ -298,10 +298,10 @@
|
|
|
onUncheckAll: function (rows) {
|
|
|
return false;
|
|
|
},
|
|
|
- onCheckSome: function(rows){
|
|
|
+ onCheckSome: function (rows) {
|
|
|
return false;
|
|
|
},
|
|
|
- onUncheckSome: function(rows){
|
|
|
+ onUncheckSome: function (rows) {
|
|
|
return false;
|
|
|
},
|
|
|
onLoadSuccess: function (data) {
|
|
|
@@ -339,6 +339,9 @@
|
|
|
},
|
|
|
onRefreshOptions: function (options) {
|
|
|
return false;
|
|
|
+ },
|
|
|
+ onResetView: function () {
|
|
|
+ return false;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -430,7 +433,8 @@
|
|
|
'post-header.bs.table': 'onPostHeader',
|
|
|
'expand-row.bs.table': 'onExpandRow',
|
|
|
'collapse-row.bs.table': 'onCollapseRow',
|
|
|
- 'refresh-options.bs.table': 'onRefreshOptions'
|
|
|
+ 'refresh-options.bs.table': 'onRefreshOptions',
|
|
|
+ 'reset-view.bs.table': 'onResetView'
|
|
|
};
|
|
|
|
|
|
BootstrapTable.prototype.init = function () {
|
|
|
@@ -450,8 +454,8 @@
|
|
|
'<div class="bootstrap-table">',
|
|
|
'<div class="fixed-table-toolbar"></div>',
|
|
|
this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ?
|
|
|
- '<div class="fixed-table-pagination" style="clear: both;"></div>' :
|
|
|
- '',
|
|
|
+ '<div class="fixed-table-pagination" style="clear: both;"></div>' :
|
|
|
+ '',
|
|
|
'<div class="fixed-table-container">',
|
|
|
'<div class="fixed-table-header"><table></table></div>',
|
|
|
'<div class="fixed-table-body">',
|
|
|
@@ -461,10 +465,11 @@
|
|
|
'</div>',
|
|
|
'<div class="fixed-table-footer"><table><tr></tr></table></div>',
|
|
|
this.options.paginationVAlign === 'bottom' || this.options.paginationVAlign === 'both' ?
|
|
|
- '<div class="fixed-table-pagination"></div>' :
|
|
|
- '',
|
|
|
+ '<div class="fixed-table-pagination"></div>' :
|
|
|
+ '',
|
|
|
'</div>',
|
|
|
- '</div>'].join(''));
|
|
|
+ '</div>'
|
|
|
+ ].join(''));
|
|
|
|
|
|
this.$container.insertAfter(this.$el);
|
|
|
this.$tableContainer = this.$container.find('.fixed-table-container');
|
|
|
@@ -509,8 +514,9 @@
|
|
|
});
|
|
|
this.options.columns = $.extend(true, [], columns, this.options.columns);
|
|
|
$.each(this.options.columns, function (i, column) {
|
|
|
- that.options.columns[i] = $.extend({}, BootstrapTable.COLUMN_DEFAULTS,
|
|
|
- {field: i}, column); // when field is undefined, use index instead
|
|
|
+ that.options.columns[i] = $.extend({}, BootstrapTable.COLUMN_DEFAULTS, {
|
|
|
+ field: i
|
|
|
+ }, column); // when field is undefined, use index instead
|
|
|
});
|
|
|
|
|
|
// if options.data is setting, do not process tbody data
|
|
|
@@ -618,8 +624,8 @@
|
|
|
|
|
|
html.push('<th',
|
|
|
column.checkbox || column.radio ?
|
|
|
- sprintf(' class="bs-checkbox %s"', column['class'] || '') :
|
|
|
- class_,
|
|
|
+ sprintf(' class="bs-checkbox %s"', column['class'] || '') :
|
|
|
+ class_,
|
|
|
sprintf(' style="%s"', halign + style),
|
|
|
'>');
|
|
|
|
|
|
@@ -823,28 +829,28 @@
|
|
|
|
|
|
if (this.options.showPaginationSwitch) {
|
|
|
html.push(sprintf('<button class="btn btn-default" type="button" name="paginationSwitch" title="%s">',
|
|
|
- this.options.formatPaginationSwitch()),
|
|
|
+ this.options.formatPaginationSwitch()),
|
|
|
sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.paginationSwitchDown),
|
|
|
'</button>');
|
|
|
}
|
|
|
|
|
|
if (this.options.showRefresh) {
|
|
|
html.push(sprintf('<button class="btn btn-default' + (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) + '" type="button" name="refresh" title="%s">',
|
|
|
- this.options.formatRefresh()),
|
|
|
+ this.options.formatRefresh()),
|
|
|
sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.refresh),
|
|
|
'</button>');
|
|
|
}
|
|
|
|
|
|
if (this.options.showToggle) {
|
|
|
html.push(sprintf('<button class="btn btn-default' + (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) + '" type="button" name="toggle" title="%s">',
|
|
|
- this.options.formatToggle()),
|
|
|
+ this.options.formatToggle()),
|
|
|
sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.toggle),
|
|
|
'</button>');
|
|
|
}
|
|
|
|
|
|
if (this.options.showColumns) {
|
|
|
html.push(sprintf('<div class="keep-open btn-group" title="%s">',
|
|
|
- this.options.formatColumns()),
|
|
|
+ this.options.formatColumns()),
|
|
|
'<button type="button" class="btn btn-default' + (this.options.iconSize == undefined ? '' : ' btn-' + this.options.iconSize) + ' dropdown-toggle" data-toggle="dropdown">',
|
|
|
sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.columns),
|
|
|
' <span class="caret"></span>',
|
|
|
@@ -987,8 +993,7 @@
|
|
|
|
|
|
// Fix #142: search use formated data
|
|
|
value = calculateObjectValue(column,
|
|
|
- that.header.formatters[j],
|
|
|
- [value, item, i], value);
|
|
|
+ that.header.formatters[j], [value, item, i], value);
|
|
|
|
|
|
var index = $.inArray(key, that.header.fields);
|
|
|
if (index !== -1 && that.header.searchables[index] &&
|
|
|
@@ -1071,7 +1076,8 @@
|
|
|
'</span>',
|
|
|
' <span class="caret"></span>',
|
|
|
'</button>',
|
|
|
- '<ul class="dropdown-menu" role="menu">'],
|
|
|
+ '<ul class="dropdown-menu" role="menu">'
|
|
|
+ ],
|
|
|
pageList = this.options.pageList;
|
|
|
|
|
|
if (typeof this.options.pageList === 'string') {
|
|
|
@@ -1364,31 +1370,32 @@
|
|
|
text = [that.options.cardView ?
|
|
|
'<div class="card-view">' : '<td class="bs-checkbox">',
|
|
|
'<input' +
|
|
|
- sprintf(' data-index="%s"', i) +
|
|
|
- sprintf(' name="%s"', that.options.selectItemName) +
|
|
|
- sprintf(' type="%s"', type) +
|
|
|
- sprintf(' value="%s"', item[that.options.idField]) +
|
|
|
- sprintf(' checked="%s"', value === true ||
|
|
|
- (value && value.checked) ? 'checked' : undefined) +
|
|
|
- sprintf(' disabled="%s"', !column.checkboxEnabled ||
|
|
|
- (value && value.disabled) ? 'disabled' : undefined) +
|
|
|
- ' />',
|
|
|
- that.options.cardView ? '</div>' : '</td>'].join('');
|
|
|
+ sprintf(' data-index="%s"', i) +
|
|
|
+ sprintf(' name="%s"', that.options.selectItemName) +
|
|
|
+ sprintf(' type="%s"', type) +
|
|
|
+ sprintf(' value="%s"', item[that.options.idField]) +
|
|
|
+ sprintf(' checked="%s"', value === true ||
|
|
|
+ (value && value.checked) ? 'checked' : undefined) +
|
|
|
+ sprintf(' disabled="%s"', !column.checkboxEnabled ||
|
|
|
+ (value && value.disabled) ? 'disabled' : undefined) +
|
|
|
+ ' />',
|
|
|
+ that.options.cardView ? '</div>' : '</td>'
|
|
|
+ ].join('');
|
|
|
|
|
|
item[that.header.stateField] = value === true || (value && value.checked);
|
|
|
} else {
|
|
|
value = typeof value === 'undefined' || value === null ?
|
|
|
that.options.undefinedText : value;
|
|
|
|
|
|
- text = that.options.cardView ?
|
|
|
- ['<div class="card-view">',
|
|
|
- that.options.showHeader ? sprintf('<span class="title" %s>%s</span>', style,
|
|
|
- getPropertyFromOther(that.options.columns, 'field', 'title', field)) : '',
|
|
|
- sprintf('<span class="value">%s</span>', value),
|
|
|
- '</div>'].join('') :
|
|
|
- [sprintf('<td%s %s %s %s %s>', id_, class_, style, data_, rowspan_),
|
|
|
- value,
|
|
|
- '</td>'].join('');
|
|
|
+ text = that.options.cardView ? ['<div class="card-view">',
|
|
|
+ that.options.showHeader ? sprintf('<span class="title" %s>%s</span>', style,
|
|
|
+ getPropertyFromOther(that.options.columns, 'field', 'title', field)) : '',
|
|
|
+ sprintf('<span class="value">%s</span>', value),
|
|
|
+ '</div>'
|
|
|
+ ].join('') : [sprintf('<td%s %s %s %s %s>', id_, class_, style, data_, rowspan_),
|
|
|
+ value,
|
|
|
+ '</td>'
|
|
|
+ ].join('');
|
|
|
|
|
|
// Hide empty data on Card view when smartDisplay is set to true.
|
|
|
if (that.options.cardView && that.options.smartDisplay && value === '') {
|
|
|
@@ -1674,10 +1681,10 @@
|
|
|
fixedBody = this.$tableBody.get(0);
|
|
|
|
|
|
scrollWidth = fixedBody.scrollWidth > fixedBody.clientWidth &&
|
|
|
- fixedBody.scrollHeight > fixedBody.clientHeight + this.$header.height() ?
|
|
|
+ fixedBody.scrollHeight > fixedBody.clientHeight + this.$header.outerHeight() ?
|
|
|
getScrollBarWidth() : 0;
|
|
|
|
|
|
- this.$el.css('margin-top', -this.$header.height());
|
|
|
+ this.$el.css('margin-top', -this.$header.outerHeight());
|
|
|
this.$header_ = this.$header.clone(true, true);
|
|
|
this.$selectAll_ = this.$header_.find('[name="btSelectAll"]');
|
|
|
this.$tableHeader.css({
|
|
|
@@ -1759,8 +1766,8 @@
|
|
|
scrollWidth = elWidth > this.$tableBody.width() ? getScrollBarWidth() : 0;
|
|
|
|
|
|
this.$tableFooter.css({
|
|
|
- 'margin-right': scrollWidth
|
|
|
- }).find('table').css('width', elWidth)
|
|
|
+ 'margin-right': scrollWidth
|
|
|
+ }).find('table').css('width', elWidth)
|
|
|
.attr('class', this.$el.attr('class'));
|
|
|
|
|
|
$footerTd = this.$tableFooter.find('td');
|
|
|
@@ -1798,8 +1805,7 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- $(this.$body[0]).children().filter(sprintf(isIdField ? '[data-uniqueid="%s"]' : '[data-index="%s"]', index))
|
|
|
- [visible ? 'show' : 'hide']();
|
|
|
+ $(this.$body[0]).children().filter(sprintf(isIdField ? '[data-uniqueid="%s"]' : '[data-index="%s"]', index))[visible ? 'show' : 'hide']();
|
|
|
};
|
|
|
|
|
|
// PUBLIC FUNCTION DEFINITION
|
|
|
@@ -1849,16 +1855,13 @@
|
|
|
// Assign the correct sortable arrow
|
|
|
this.getCaret();
|
|
|
this.$tableContainer.css('padding-bottom', padding + 'px');
|
|
|
+ this.trigger('reset-view');
|
|
|
};
|
|
|
|
|
|
BootstrapTable.prototype.getData = function (useCurrentPage) {
|
|
|
- return (this.searchText
|
|
|
- || !$.isEmptyObject(this.filterColumns)
|
|
|
- || !$.isEmptyObject(this.filterColumnsPartial)) ?
|
|
|
- (useCurrentPage ? this.data.slice(this.pageFrom -1, this.pageTo)
|
|
|
- : this.data) :
|
|
|
- (useCurrentPage ? this.options.data.slice(this.pageFrom - 1, this.pageTo)
|
|
|
- : this.options.data);
|
|
|
+ return (this.searchText || !$.isEmptyObject(this.filterColumns) || !$.isEmptyObject(this.filterColumnsPartial)) ?
|
|
|
+ (useCurrentPage ? this.data.slice(this.pageFrom - 1, this.pageTo) : this.data) :
|
|
|
+ (useCurrentPage ? this.options.data.slice(this.pageFrom - 1, this.pageTo) : this.options.data);
|
|
|
};
|
|
|
|
|
|
BootstrapTable.prototype.load = function (data) {
|