|
@@ -248,9 +248,6 @@
|
|
|
onColumnSwitch: function (field, checked) {
|
|
onColumnSwitch: function (field, checked) {
|
|
|
return false;
|
|
return false;
|
|
|
},
|
|
},
|
|
|
- onColumnSearch: function (field, text) {
|
|
|
|
|
- return false;
|
|
|
|
|
- },
|
|
|
|
|
onPageChange: function (number, size) {
|
|
onPageChange: function (number, size) {
|
|
|
return false;
|
|
return false;
|
|
|
},
|
|
},
|
|
@@ -332,8 +329,7 @@
|
|
|
sortName: undefined,
|
|
sortName: undefined,
|
|
|
cellStyle: undefined,
|
|
cellStyle: undefined,
|
|
|
searchable: true,
|
|
searchable: true,
|
|
|
- cardVisible: true,
|
|
|
|
|
- filterControl: undefined // edit, select, todo: date
|
|
|
|
|
|
|
+ cardVisible: true
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
BootstrapTable.EVENTS = {
|
|
BootstrapTable.EVENTS = {
|
|
@@ -348,7 +344,6 @@
|
|
|
'load-success.bs.table': 'onLoadSuccess',
|
|
'load-success.bs.table': 'onLoadSuccess',
|
|
|
'load-error.bs.table': 'onLoadError',
|
|
'load-error.bs.table': 'onLoadError',
|
|
|
'column-switch.bs.table': 'onColumnSwitch',
|
|
'column-switch.bs.table': 'onColumnSwitch',
|
|
|
- 'column-search.bs.table': 'onColumnSearch',
|
|
|
|
|
'page-change.bs.table': 'onPageChange',
|
|
'page-change.bs.table': 'onPageChange',
|
|
|
'search.bs.table': 'onSearch',
|
|
'search.bs.table': 'onSearch',
|
|
|
'toggle.bs.table': 'onToggle',
|
|
'toggle.bs.table': 'onToggle',
|
|
@@ -457,7 +452,6 @@
|
|
|
var that = this,
|
|
var that = this,
|
|
|
visibleColumns = [],
|
|
visibleColumns = [],
|
|
|
html = [],
|
|
html = [],
|
|
|
- addedFilterControl = false,
|
|
|
|
|
timeoutId = 0;
|
|
timeoutId = 0;
|
|
|
|
|
|
|
|
this.header = {
|
|
this.header = {
|
|
@@ -481,8 +475,7 @@
|
|
|
class_ = sprintf(' class="%s"', column['class']),
|
|
class_ = sprintf(' class="%s"', column['class']),
|
|
|
order = that.options.sortOrder || column.order,
|
|
order = that.options.sortOrder || column.order,
|
|
|
searchable = true,
|
|
searchable = true,
|
|
|
- unitWidth = 'px',
|
|
|
|
|
- isVisible = 'hidden';
|
|
|
|
|
|
|
+ unitWidth = 'px';
|
|
|
|
|
|
|
|
if (!column.visible) {
|
|
if (!column.visible) {
|
|
|
// Fix #229. Default Sort order is wrong if data-visible="false" is set on the field referenced by data-sort-name.
|
|
// Fix #229. Default Sort order is wrong if data-visible="false" is set on the field referenced by data-sort-name.
|
|
@@ -554,30 +547,7 @@
|
|
|
html.push(text);
|
|
html.push(text);
|
|
|
html.push('</div>');
|
|
html.push('</div>');
|
|
|
html.push('<div class="fht-cell"></div>');
|
|
html.push('<div class="fht-cell"></div>');
|
|
|
-
|
|
|
|
|
- html.push('<div style="margin: 0px 2px 2px 2px;" class="filterControl">');
|
|
|
|
|
-
|
|
|
|
|
- if (column.filterControl && column.searchable) {
|
|
|
|
|
- addedFilterControl = true;
|
|
|
|
|
- isVisible = 'visible'
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (column.filterControl !== undefined) {
|
|
|
|
|
- switch (column.filterControl.toLowerCase()) {
|
|
|
|
|
- case 'input' :
|
|
|
|
|
- html.push(sprintf('<input type="text" class="form-control" style="width: 100%; visibility: %s">', isVisible));
|
|
|
|
|
- break;
|
|
|
|
|
- case 'select':
|
|
|
|
|
- html.push(sprintf('<select class="%s form-control" style="width: 100%; visibility: %s"></select>',
|
|
|
|
|
- column.field, isVisible))
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- html.push('<div style="height: 34px;"></div>');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
html.push('</div>');
|
|
html.push('</div>');
|
|
|
-
|
|
|
|
|
html.push('</th>');
|
|
html.push('</th>');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -607,24 +577,6 @@
|
|
|
var checked = $(this).prop('checked');
|
|
var checked = $(this).prop('checked');
|
|
|
that[checked ? 'checkAll' : 'uncheckAll']();
|
|
that[checked ? 'checkAll' : 'uncheckAll']();
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
- if (addedFilterControl) {
|
|
|
|
|
- this.$header.off('keyup', 'input').on('keyup', 'input', function (event) {
|
|
|
|
|
- clearTimeout(timeoutId);
|
|
|
|
|
- timeoutId = setTimeout(function () {
|
|
|
|
|
- that.onColumnSearch(event);
|
|
|
|
|
- }, that.options.searchTimeOut);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- this.$header.off('change', 'select').on('change', 'select', function (event) {
|
|
|
|
|
- clearTimeout(timeoutId);
|
|
|
|
|
- timeoutId = setTimeout(function () {
|
|
|
|
|
- that.onColumnSearch(event);
|
|
|
|
|
- }, that.options.searchTimeOut);
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$header.find('.filterControl').hide();
|
|
|
|
|
- }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
BootstrapTable.prototype.initFooter = function () {
|
|
BootstrapTable.prototype.initFooter = function () {
|
|
@@ -902,32 +854,12 @@
|
|
|
this.trigger('search', text);
|
|
this.trigger('search', text);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- BootstrapTable.prototype.onColumnSearch = function (event, isSelectControl) {
|
|
|
|
|
- var text = $.trim($(event.currentTarget).val());
|
|
|
|
|
- var $field = $(event.currentTarget).parent().parent().data('field')
|
|
|
|
|
-
|
|
|
|
|
- if ($.isEmptyObject(this.filterColumnsPartial)) {
|
|
|
|
|
- this.filterColumnsPartial = {};
|
|
|
|
|
- }
|
|
|
|
|
- if (text) {
|
|
|
|
|
- this.filterColumnsPartial[$field] = text;
|
|
|
|
|
- } else {
|
|
|
|
|
- delete this.filterColumnsPartial[$field];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- this.options.pageNumber = 1;
|
|
|
|
|
- this.onSearch(event);
|
|
|
|
|
- this.updatePagination();
|
|
|
|
|
- this.trigger('column-search', $field, text);
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
BootstrapTable.prototype.initSearch = function () {
|
|
BootstrapTable.prototype.initSearch = function () {
|
|
|
var that = this;
|
|
var that = this;
|
|
|
|
|
|
|
|
if (this.options.sidePagination !== 'server') {
|
|
if (this.options.sidePagination !== 'server') {
|
|
|
var s = this.searchText && this.searchText.toLowerCase();
|
|
var s = this.searchText && this.searchText.toLowerCase();
|
|
|
var f = $.isEmptyObject(this.filterColumns) ? null : this.filterColumns;
|
|
var f = $.isEmptyObject(this.filterColumns) ? null : this.filterColumns;
|
|
|
- var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial;
|
|
|
|
|
|
|
|
|
|
// Check filter
|
|
// Check filter
|
|
|
this.data = f ? $.grep(this.options.data, function (item, i) {
|
|
this.data = f ? $.grep(this.options.data, function (item, i) {
|
|
@@ -939,24 +871,6 @@
|
|
|
return true;
|
|
return true;
|
|
|
}) : this.options.data;
|
|
}) : this.options.data;
|
|
|
|
|
|
|
|
- //Check partial colum filter
|
|
|
|
|
- this.data = fp ? $.grep(this.data, function (item, i) {
|
|
|
|
|
- for (var key in fp) {
|
|
|
|
|
- var fval = fp[key].toLowerCase();
|
|
|
|
|
- var value = item[key];
|
|
|
|
|
- value = calculateObjectValue(that.header,
|
|
|
|
|
- that.header.formatters[$.inArray(key, that.header.fields)],
|
|
|
|
|
- [value, item, i], value);
|
|
|
|
|
-
|
|
|
|
|
- if (!($.inArray(key, that.header.fields) !== -1 &&
|
|
|
|
|
- (typeof value === 'string' || typeof value === 'number') &&
|
|
|
|
|
- (value + '').toLowerCase().indexOf(fval) !== -1)) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return true;
|
|
|
|
|
- }) : this.data;
|
|
|
|
|
-
|
|
|
|
|
this.data = s ? $.grep(this.data, function (item, i) {
|
|
this.data = s ? $.grep(this.data, function (item, i) {
|
|
|
for (var key in item) {
|
|
for (var key in item) {
|
|
|
key = $.isNumeric(key) ? parseInt(key, 10) : key;
|
|
key = $.isNumeric(key) ? parseInt(key, 10) : key;
|
|
@@ -1344,43 +1258,6 @@
|
|
|
value,
|
|
value,
|
|
|
'</td>'].join('');
|
|
'</td>'].join('');
|
|
|
|
|
|
|
|
- if (column.filterControl !== undefined && column.filterControl.toLowerCase() === 'select'
|
|
|
|
|
- && column.searchable) {
|
|
|
|
|
-
|
|
|
|
|
- var selectControl = $('.' + column.field),
|
|
|
|
|
- iOpt = 0,
|
|
|
|
|
- exitsOpt = false,
|
|
|
|
|
- options;
|
|
|
|
|
- if (selectControl !== undefined) {
|
|
|
|
|
- options = selectControl.get(0).options;
|
|
|
|
|
-
|
|
|
|
|
- if (options.length === 0) {
|
|
|
|
|
-
|
|
|
|
|
- //Added the default option
|
|
|
|
|
- selectControl.append($("<option></option>")
|
|
|
|
|
- .attr("value", '')
|
|
|
|
|
- .text(''));
|
|
|
|
|
-
|
|
|
|
|
- selectControl.append($("<option></option>")
|
|
|
|
|
- .attr("value", value)
|
|
|
|
|
- .text(value));
|
|
|
|
|
- } else {
|
|
|
|
|
- for (; iOpt < options.length; iOpt++) {
|
|
|
|
|
- if (options[iOpt].value === value) {
|
|
|
|
|
- exitsOpt = true;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!exitsOpt) {
|
|
|
|
|
- selectControl.append($("<option></option>")
|
|
|
|
|
- .attr("value", value)
|
|
|
|
|
- .text(value));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// Hide empty data on Card view when smartDisplay is set to true.
|
|
// Hide empty data on Card view when smartDisplay is set to true.
|
|
|
if (that.options.cardView && that.options.smartDisplay && value === '') {
|
|
if (that.options.cardView && that.options.smartDisplay && value === '') {
|
|
|
text = '';
|
|
text = '';
|