|
@@ -4,7 +4,7 @@
|
|
|
* https://github.com/wenzhixin/bootstrap-table/
|
|
* https://github.com/wenzhixin/bootstrap-table/
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-! function ($) {
|
|
|
|
|
|
|
+!function ($) {
|
|
|
'use strict';
|
|
'use strict';
|
|
|
|
|
|
|
|
// TOOLS DEFINITION
|
|
// TOOLS DEFINITION
|
|
@@ -95,7 +95,7 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
var getScrollBarWidth = function () {
|
|
var getScrollBarWidth = function () {
|
|
|
if (cachedWidth === null) {
|
|
if (cachedWidth === null) {
|
|
@@ -211,6 +211,15 @@
|
|
|
return dataAttr;
|
|
return dataAttr;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ var getItemField = function (item, field) {
|
|
|
|
|
+ var props = field.split('.');
|
|
|
|
|
+ var value = item;
|
|
|
|
|
+ for (var p in props) {
|
|
|
|
|
+ value = value[props[p]];
|
|
|
|
|
+ }
|
|
|
|
|
+ return value;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// BOOTSTRAP TABLE CLASS DEFINITION
|
|
// BOOTSTRAP TABLE CLASS DEFINITION
|
|
|
// ======================
|
|
// ======================
|
|
|
|
|
|
|
@@ -234,6 +243,7 @@
|
|
|
striped: false,
|
|
striped: false,
|
|
|
columns: [[]],
|
|
columns: [[]],
|
|
|
data: [],
|
|
data: [],
|
|
|
|
|
+ dataField: 'rows',
|
|
|
method: 'get',
|
|
method: 'get',
|
|
|
url: undefined,
|
|
url: undefined,
|
|
|
ajax: undefined,
|
|
ajax: undefined,
|
|
@@ -514,26 +524,26 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
BootstrapTable.prototype.initContainer = function () {
|
|
BootstrapTable.prototype.initContainer = function () {
|
|
|
this.$container = $([
|
|
this.$container = $([
|
|
|
'<div class="bootstrap-table">',
|
|
'<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-container">',
|
|
|
|
|
- '<div class="fixed-table-header"><table></table></div>',
|
|
|
|
|
- '<div class="fixed-table-body">',
|
|
|
|
|
- '<div class="fixed-table-loading">',
|
|
|
|
|
- this.options.formatLoadingMessage(),
|
|
|
|
|
- '</div>',
|
|
|
|
|
- '</div>',
|
|
|
|
|
- '<div class="fixed-table-footer"><table><tr></tr></table></div>',
|
|
|
|
|
- this.options.paginationVAlign === 'bottom' || this.options.paginationVAlign === 'both' ?
|
|
|
|
|
|
|
+ '<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-container">',
|
|
|
|
|
+ '<div class="fixed-table-header"><table></table></div>',
|
|
|
|
|
+ '<div class="fixed-table-body">',
|
|
|
|
|
+ '<div class="fixed-table-loading">',
|
|
|
|
|
+ this.options.formatLoadingMessage(),
|
|
|
|
|
+ '</div>',
|
|
|
|
|
+ '</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>',
|
|
|
'</div>'
|
|
'</div>'
|
|
|
].join(''));
|
|
].join(''));
|
|
|
|
|
|
|
@@ -704,12 +714,13 @@
|
|
|
|
|
|
|
|
html.push('<th' + sprintf(' title="%s"', column.titleTooltip),
|
|
html.push('<th' + sprintf(' title="%s"', column.titleTooltip),
|
|
|
column.checkbox || column.radio ?
|
|
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),
|
|
sprintf(' style="%s"', halign + style),
|
|
|
sprintf(' rowspan="%s"', column.rowspan),
|
|
sprintf(' rowspan="%s"', column.rowspan),
|
|
|
sprintf(' colspan="%s"', column.colspan),
|
|
sprintf(' colspan="%s"', column.colspan),
|
|
|
sprintf(' data-field="%s"', column.field),
|
|
sprintf(' data-field="%s"', column.field),
|
|
|
|
|
+ "tabindex='0'",
|
|
|
'>');
|
|
'>');
|
|
|
|
|
|
|
|
html.push(sprintf('<div class="th-inner %s">', that.options.sortable && column.sortable ?
|
|
html.push(sprintf('<div class="th-inner %s">', that.options.sortable && column.sortable ?
|
|
@@ -748,6 +759,15 @@
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ this.$header.children().children().off('keypress').on('keypress', function (event) {
|
|
|
|
|
+ if (that.options.sortable && $(this).data().sortable) {
|
|
|
|
|
+ var code = event.keyCode || event.which;
|
|
|
|
|
+ if (code == 13) { //Enter keycode
|
|
|
|
|
+ that.onSort(event);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
if (!this.options.showHeader || this.options.cardView) {
|
|
if (!this.options.showHeader || this.options.cardView) {
|
|
|
this.$header.hide();
|
|
this.$header.hide();
|
|
|
this.$tableHeader.hide();
|
|
this.$tableHeader.hide();
|
|
@@ -815,8 +835,8 @@
|
|
|
if (that.header.sortNames[index]) {
|
|
if (that.header.sortNames[index]) {
|
|
|
name = that.header.sortNames[index];
|
|
name = that.header.sortNames[index];
|
|
|
}
|
|
}
|
|
|
- var aa = a[name],
|
|
|
|
|
- bb = b[name],
|
|
|
|
|
|
|
+ var aa = getItemField(a, name),
|
|
|
|
|
+ bb = getItemField(b, name),
|
|
|
value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
|
|
value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
|
|
|
|
|
|
|
|
if (value !== undefined) {
|
|
if (value !== undefined) {
|
|
@@ -861,7 +881,7 @@
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
BootstrapTable.prototype.onSort = function (event) {
|
|
BootstrapTable.prototype.onSort = function (event) {
|
|
|
- var $this = $(event.currentTarget).parent(),
|
|
|
|
|
|
|
+ var $this = event.type === "keypress" ? $(event.currentTarget) : $(event.currentTarget).parent(),
|
|
|
$this_ = this.$header.find('th').eq($this.index());
|
|
$this_ = this.$header.find('th').eq($this.index());
|
|
|
|
|
|
|
|
this.$header.add(this.$header_).find('span.order').remove();
|
|
this.$header.add(this.$header_).find('span.order').remove();
|
|
@@ -1083,7 +1103,7 @@
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
if ((value + '').toLowerCase().indexOf(s) !== -1) {
|
|
if ((value + '').toLowerCase().indexOf(s) !== -1) {
|
|
|
- return true;
|
|
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1156,10 +1176,10 @@
|
|
|
var pageNumber = [
|
|
var pageNumber = [
|
|
|
sprintf('<span class="btn-group %s">',
|
|
sprintf('<span class="btn-group %s">',
|
|
|
this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ?
|
|
this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ?
|
|
|
- 'dropdown' : 'dropup'),
|
|
|
|
|
|
|
+ 'dropdown' : 'dropup'),
|
|
|
'<button type="button" class="btn btn-default ' +
|
|
'<button type="button" class="btn btn-default ' +
|
|
|
- (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) +
|
|
|
|
|
- ' dropdown-toggle" data-toggle="dropdown">',
|
|
|
|
|
|
|
+ (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) +
|
|
|
|
|
+ ' dropdown-toggle" data-toggle="dropdown">',
|
|
|
'<span class="page-size">',
|
|
'<span class="page-size">',
|
|
|
$allSelected ? this.options.formatAllRows() : this.options.pageSize,
|
|
$allSelected ? this.options.formatAllRows() : this.options.pageSize,
|
|
|
'</span>',
|
|
'</span>',
|
|
@@ -1406,7 +1426,7 @@
|
|
|
|
|
|
|
|
$.each(this.header.fields, function (j, field) {
|
|
$.each(this.header.fields, function (j, field) {
|
|
|
var text = '',
|
|
var text = '',
|
|
|
- value = item[field],
|
|
|
|
|
|
|
+ value = getItemField(item, field),
|
|
|
type = '',
|
|
type = '',
|
|
|
cellStyle = {},
|
|
cellStyle = {},
|
|
|
id_ = '',
|
|
id_ = '',
|
|
@@ -1473,9 +1493,9 @@
|
|
|
sprintf(' type="%s"', type) +
|
|
sprintf(' type="%s"', type) +
|
|
|
sprintf(' value="%s"', item[that.options.idField]) +
|
|
sprintf(' value="%s"', item[that.options.idField]) +
|
|
|
sprintf(' checked="%s"', value === true ||
|
|
sprintf(' checked="%s"', value === true ||
|
|
|
- (value && value.checked) ? 'checked' : undefined) +
|
|
|
|
|
|
|
+ (value && value.checked) ? 'checked' : undefined) +
|
|
|
sprintf(' disabled="%s"', !column.checkboxEnabled ||
|
|
sprintf(' disabled="%s"', !column.checkboxEnabled ||
|
|
|
- (value && value.disabled) ? 'disabled' : undefined) +
|
|
|
|
|
|
|
+ (value && value.disabled) ? 'disabled' : undefined) +
|
|
|
' />',
|
|
' />',
|
|
|
that.options.cardView ? '</div>' : '</td>'
|
|
that.options.cardView ? '</div>' : '</td>'
|
|
|
].join('');
|
|
].join('');
|
|
@@ -1533,7 +1553,7 @@
|
|
|
index = $td[0].cellIndex,
|
|
index = $td[0].cellIndex,
|
|
|
field = that.header.fields[that.options.detailView && !that.options.cardView ? index - 1 : index],
|
|
field = that.header.fields[that.options.detailView && !that.options.cardView ? index - 1 : index],
|
|
|
colomn = that.columns[getFieldIndex(that.columns, field)],
|
|
colomn = that.columns[getFieldIndex(that.columns, field)],
|
|
|
- value = item[field];
|
|
|
|
|
|
|
+ value = getItemField(item, field);
|
|
|
|
|
|
|
|
if ($td.find('.detail-icon').length) {
|
|
if ($td.find('.detail-icon').length) {
|
|
|
return;
|
|
return;
|
|
@@ -1696,7 +1716,7 @@
|
|
|
that.trigger('load-success', res);
|
|
that.trigger('load-success', res);
|
|
|
},
|
|
},
|
|
|
error: function (res) {
|
|
error: function (res) {
|
|
|
- that.trigger('load-error', res.status);
|
|
|
|
|
|
|
+ that.trigger('load-error', res.status, res);
|
|
|
},
|
|
},
|
|
|
complete: function () {
|
|
complete: function () {
|
|
|
if (!silent) {
|
|
if (!silent) {
|
|
@@ -1794,19 +1814,19 @@
|
|
|
fixedBody = this.$tableBody.get(0);
|
|
fixedBody = this.$tableBody.get(0);
|
|
|
|
|
|
|
|
scrollWidth = fixedBody.scrollWidth > fixedBody.clientWidth &&
|
|
scrollWidth = fixedBody.scrollWidth > fixedBody.clientWidth &&
|
|
|
- fixedBody.scrollHeight > fixedBody.clientHeight + this.$header.outerHeight() ?
|
|
|
|
|
|
|
+ fixedBody.scrollHeight > fixedBody.clientHeight + this.$header.outerHeight() ?
|
|
|
getScrollBarWidth() : 0;
|
|
getScrollBarWidth() : 0;
|
|
|
|
|
|
|
|
this.$el.css('margin-top', -this.$header.outerHeight());
|
|
this.$el.css('margin-top', -this.$header.outerHeight());
|
|
|
|
|
|
|
|
focused = $(':focus');
|
|
focused = $(':focus');
|
|
|
- if(focused.length > 0) {
|
|
|
|
|
|
|
+ if (focused.length > 0) {
|
|
|
var $th = focused.parents('th');
|
|
var $th = focused.parents('th');
|
|
|
- if($th.length > 0) {
|
|
|
|
|
|
|
+ if ($th.length > 0) {
|
|
|
var dataField = $th.attr('data-field');
|
|
var dataField = $th.attr('data-field');
|
|
|
- if(dataField !== undefined) {
|
|
|
|
|
|
|
+ if (dataField !== undefined) {
|
|
|
var $headerTh = this.$header.find("[data-field='" + dataField + "']");
|
|
var $headerTh = this.$header.find("[data-field='" + dataField + "']");
|
|
|
- if($headerTh.length > 0) {
|
|
|
|
|
|
|
+ if ($headerTh.length > 0) {
|
|
|
$headerTh.find(":input").addClass("focus-temp");
|
|
$headerTh.find(":input").addClass("focus-temp");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1823,7 +1843,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
focusedTemp = $('.focus-temp:visible:eq(0)');
|
|
focusedTemp = $('.focus-temp:visible:eq(0)');
|
|
|
- if(focusedTemp.length > 0) {
|
|
|
|
|
|
|
+ if (focusedTemp.length > 0) {
|
|
|
focusedTemp.focus();
|
|
focusedTemp.focus();
|
|
|
this.$header.find('.focus-temp').removeClass('focus-temp');
|
|
this.$header.find('.focus-temp').removeClass('focus-temp');
|
|
|
}
|
|
}
|
|
@@ -1923,8 +1943,8 @@
|
|
|
scrollWidth = elWidth > this.$tableBody.width() ? getScrollBarWidth() : 0;
|
|
scrollWidth = elWidth > this.$tableBody.width() ? getScrollBarWidth() : 0;
|
|
|
|
|
|
|
|
this.$tableFooter.css({
|
|
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'));
|
|
.attr('class', this.$el.attr('class'));
|
|
|
|
|
|
|
|
$footerTd = this.$tableFooter.find('td');
|
|
$footerTd = this.$tableFooter.find('td');
|
|
@@ -2045,7 +2065,7 @@
|
|
|
if (this.options.sidePagination === 'server') {
|
|
if (this.options.sidePagination === 'server') {
|
|
|
this.options.totalRows = data.total;
|
|
this.options.totalRows = data.total;
|
|
|
fixedScroll = data.fixedScroll;
|
|
fixedScroll = data.fixedScroll;
|
|
|
- data = data.rows;
|
|
|
|
|
|
|
+ data = data[this.options.dataField];
|
|
|
} else if (!$.isArray(data)) { // support fixedScroll
|
|
} else if (!$.isArray(data)) { // support fixedScroll
|
|
|
fixedScroll = data.fixedScroll;
|
|
fixedScroll = data.fixedScroll;
|
|
|
data = data.data;
|
|
data = data.data;
|
|
@@ -2383,7 +2403,7 @@
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
BootstrapTable.prototype.getHiddenColumns = function () {
|
|
BootstrapTable.prototype.getHiddenColumns = function () {
|
|
|
- return $.grep(this.columns, function( column ) {
|
|
|
|
|
|
|
+ return $.grep(this.columns, function (column) {
|
|
|
return !column.visible;
|
|
return !column.visible;
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
@@ -2458,6 +2478,20 @@
|
|
|
this.onSearch({currentTarget: $search});
|
|
this.onSearch({currentTarget: $search});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ BootstrapTable.prototype.expandRow = function (index) {
|
|
|
|
|
+ var $tr = this.$body.find(sprintf('> tr[data-index="%s"]', index));
|
|
|
|
|
+ if (!$tr.next().is('tr.detail-view')) {
|
|
|
|
|
+ $tr.find('> td > .detail-icon').click();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ BootstrapTable.prototype.collapseRow = function (index) {
|
|
|
|
|
+ var $tr = this.$body.find(sprintf('> tr[data-index="%s"]', index));
|
|
|
|
|
+ if ($tr.next().is('tr.detail-view')) {
|
|
|
|
|
+ $tr.find('> td > .detail-icon').click();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
// BOOTSTRAP TABLE PLUGIN DEFINITION
|
|
// BOOTSTRAP TABLE PLUGIN DEFINITION
|
|
|
// =======================
|
|
// =======================
|
|
|
|
|
|
|
@@ -2484,7 +2518,8 @@
|
|
|
'togglePagination',
|
|
'togglePagination',
|
|
|
'toggleView',
|
|
'toggleView',
|
|
|
'refreshOptions',
|
|
'refreshOptions',
|
|
|
- 'resetSearch'
|
|
|
|
|
|
|
+ 'resetSearch',
|
|
|
|
|
+ 'expandRow', 'collapseRow'
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
$.fn.bootstrapTable = function (option) {
|
|
$.fn.bootstrapTable = function (option) {
|
|
@@ -2526,6 +2561,12 @@
|
|
|
$.fn.bootstrapTable.columnDefaults = BootstrapTable.COLUMN_DEFAULTS;
|
|
$.fn.bootstrapTable.columnDefaults = BootstrapTable.COLUMN_DEFAULTS;
|
|
|
$.fn.bootstrapTable.locales = BootstrapTable.LOCALES;
|
|
$.fn.bootstrapTable.locales = BootstrapTable.LOCALES;
|
|
|
$.fn.bootstrapTable.methods = allowedMethods;
|
|
$.fn.bootstrapTable.methods = allowedMethods;
|
|
|
|
|
+ $.fn.bootstrapTable.utils = {
|
|
|
|
|
+ sprintf: sprintf,
|
|
|
|
|
+ getFieldIndex: getFieldIndex,
|
|
|
|
|
+ compareObjects: compareObjects,
|
|
|
|
|
+ calculateObjectValue: calculateObjectValue
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
// BOOTSTRAP TABLE INIT
|
|
// BOOTSTRAP TABLE INIT
|
|
|
// =======================
|
|
// =======================
|