bootstrap-table-rails 1.11.1.1 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -7
- data/README.md +6 -3
- data/lib/bootstrap-table-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-table-locale-all.js +374 -6
- data/vendor/assets/javascripts/bootstrap-table.js +348 -147
- data/vendor/assets/javascripts/extensions/bootstrap-table-accent-neutralise.js +1 -1
- data/vendor/assets/javascripts/extensions/bootstrap-table-angular.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-auto-refresh.js +62 -62
- data/vendor/assets/javascripts/extensions/bootstrap-table-click-edit-row.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-cookie.js +48 -69
- data/vendor/assets/javascripts/extensions/bootstrap-table-copy-rows.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-defer-url.js +32 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-editable.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-export.js +56 -8
- data/vendor/assets/javascripts/extensions/bootstrap-table-filter-control.js +93 -46
- data/vendor/assets/javascripts/extensions/bootstrap-table-filter.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-flat-json.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-group-by-v2.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-group-by.js +2 -2
- data/vendor/assets/javascripts/extensions/bootstrap-table-i18n-enhance.js +3 -2
- data/vendor/assets/javascripts/extensions/bootstrap-table-jumpto.js +50 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-key-events.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-mobile.js +1 -1
- data/vendor/assets/javascripts/extensions/bootstrap-table-multi-toggle.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-multiple-search.js +1 -1
- data/vendor/assets/javascripts/extensions/bootstrap-table-multiple-selection-row.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-multiple-sort.js +31 -12
- data/vendor/assets/javascripts/extensions/bootstrap-table-natural-sorting.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-print.js +33 -17
- data/vendor/assets/javascripts/extensions/bootstrap-table-reorder-columns.js +2 -2
- data/vendor/assets/javascripts/extensions/bootstrap-table-reorder-rows.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-resizable.js +2 -1
- data/vendor/assets/javascripts/extensions/bootstrap-table-select2-filter.js +136 -107
- data/vendor/assets/javascripts/extensions/bootstrap-table-sticky-header.js +11 -4
- data/vendor/assets/javascripts/extensions/bootstrap-table-toolbar.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-tree-column.js +0 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-treegrid.js +95 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-af-ZA.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ar-SA.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ca-ES.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-cs-CZ.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-da-DK.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-de-DE.js +14 -5
- data/vendor/assets/javascripts/locale/bootstrap-table-el-GR.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-en-US.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-es-AR.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-es-CL.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-es-CR.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-es-ES.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-es-MX.js +20 -1
- data/vendor/assets/javascripts/locale/bootstrap-table-es-NI.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-es-SP.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-et-EE.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-eu-EU.js +43 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-fa-IR.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-fr-BE.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-fr-FR.js +54 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-he-IL.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-hr-HR.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-hu-HU.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-id-ID.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-it-IT.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ja-JP.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ka-GE.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ko-KR.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ms-MY.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-nb-NO.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-nl-NL.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-pl-PL.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-pt-BR.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-pt-PT.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ro-RO.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ru-RU.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-sk-SK.js +12 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-sv-SE.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-th-TH.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-tr-TR.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-uk-UA.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ur-PK.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-uz-Latn-UZ.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-vi-VN.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-zh-CN.js +0 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-zh-TW.js +0 -0
- data/vendor/assets/stylesheets/bootstrap-table.css +11 -6
- data/vendor/assets/stylesheets/extensions/bootstrap-table-auto-refresh.css +1 -1
- data/vendor/assets/stylesheets/extensions/bootstrap-table-click-edit-row.css +0 -0
- data/vendor/assets/stylesheets/extensions/bootstrap-table-filter-control.css +0 -0
- data/vendor/assets/stylesheets/extensions/bootstrap-table-group-by-v2.css +0 -0
- data/vendor/assets/stylesheets/extensions/bootstrap-table-group-by.css +0 -0
- data/vendor/assets/stylesheets/extensions/bootstrap-table-jumpto.css +8 -0
- data/vendor/assets/stylesheets/extensions/bootstrap-table-multiple-selection-row.css +0 -0
- data/vendor/assets/stylesheets/extensions/bootstrap-table-reorder-rows.css +0 -0
- data/vendor/assets/stylesheets/extensions/bootstrap-table-sticky-header.css +0 -0
- data/vendor/assets/stylesheets/extensions/bootstrap-table-tree-column.css +0 -0
- metadata +49 -50
- data/vendor/assets/javascripts/locale/README.md +0 -179
- data/vendor/assets/javascripts/locale/bootstrap-table-en-US.js.template +0 -49
File without changes
|
@@ -24,6 +24,7 @@
|
|
24
24
|
printAsFilteredAndSortedOnUI: true, //boolean, when true - print table as sorted and filtered on UI.
|
25
25
|
//Please note that if true is set, along with explicit predefined print options for filtering and sorting (printFilter, printSortOrder, printSortColumn)- then they will be applied on data already filtered and sorted by UI controls.
|
26
26
|
//For printing data as filtered and sorted on UI - do not set these 3 options:printFilter, printSortOrder, printSortColumn
|
27
|
+
|
27
28
|
printSortColumn: undefined , //String, set column field name to be sorted by
|
28
29
|
printSortOrder: 'asc', //String: 'asc' , 'desc' - relevant only if printSortColumn is set
|
29
30
|
printPageBuilder: function(table){return printPageBuilderDefault(table)} // function, receive html <table> element as string, returns html string for printing. by default delegates to function printPageBuilderDefault(table). used for styling and adding header or footer
|
@@ -32,6 +33,7 @@
|
|
32
33
|
printFilter: undefined, //set value to filter by in print page
|
33
34
|
printIgnore: false, //boolean, set true to ignore this column in the print page
|
34
35
|
printFormatter:undefined //function(value, row, index), formats the cell value for this column in the printed table. Function behaviour is similar to the 'formatter' column option
|
36
|
+
|
35
37
|
});
|
36
38
|
$.extend($.fn.bootstrapTable.defaults.icons, {
|
37
39
|
print: 'glyphicon-print icon-share'
|
@@ -41,7 +43,7 @@
|
|
41
43
|
_initToolbar = BootstrapTable.prototype.initToolbar;
|
42
44
|
|
43
45
|
BootstrapTable.prototype.initToolbar = function () {
|
44
|
-
this.showToolbar = this.options.showPrint;
|
46
|
+
this.showToolbar = this.showToolbar || this.options.showPrint;
|
45
47
|
|
46
48
|
_initToolbar.apply(this, Array.prototype.slice.apply(arguments));
|
47
49
|
|
@@ -63,28 +65,42 @@
|
|
63
65
|
return column.printFormatter.apply(column, [value, row, i]);
|
64
66
|
}
|
65
67
|
else {
|
66
|
-
return value
|
68
|
+
return typeof value === 'undefined' ? "-" : value;
|
67
69
|
}
|
68
70
|
}
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
|
72
|
+
function buildTable(data, columnsArray) {
|
73
|
+
var html = ['<table><thead>'];
|
74
|
+
for (var k = 0; k < columnsArray.length; k++) {
|
75
|
+
var columns = columnsArray[k];
|
76
|
+
html.push('<tr>');
|
77
|
+
for (var h = 0; h < columns.length; h++) {
|
78
|
+
if (!columns[h].printIgnore) {
|
79
|
+
html.push(
|
80
|
+
'<th',
|
81
|
+
sprintf(' rowspan="%s"', columns[h].rowspan),
|
82
|
+
sprintf(' colspan="%s"', columns[h].colspan),
|
83
|
+
sprintf('>%s</th>', columns[h].title)
|
84
|
+
);
|
85
|
+
}
|
74
86
|
}
|
87
|
+
html.push('</tr>');
|
75
88
|
}
|
76
|
-
|
77
|
-
for(var i = 0; i < data.length; i++) {
|
78
|
-
|
79
|
-
for(var
|
80
|
-
|
81
|
-
|
89
|
+
html.push('</thead><tbody>');
|
90
|
+
for (var i = 0; i < data.length; i++) {
|
91
|
+
html.push('<tr>');
|
92
|
+
for(var l = 0; l < columnsArray.length; l++) {
|
93
|
+
var columns = columnsArray[l];
|
94
|
+
for(var j = 0; j < columns.length; j++) {
|
95
|
+
if (!columns[j].printIgnore && columns[j].field) {
|
96
|
+
html.push('<td>', formatValue(data[i], i, columns[j]), '</td>');
|
97
|
+
}
|
82
98
|
}
|
83
99
|
}
|
84
|
-
|
100
|
+
html.push('</tr>');
|
85
101
|
}
|
86
|
-
|
87
|
-
return
|
102
|
+
html.push('</tbody></table>');
|
103
|
+
return html.join('');
|
88
104
|
}
|
89
105
|
function sortRows(data,colName,sortOrder) {
|
90
106
|
if(!colName){
|
@@ -119,7 +135,7 @@
|
|
119
135
|
var doPrint = function (data) {
|
120
136
|
data=filterRows(data,getColumnFilters(that.options.columns));
|
121
137
|
data=sortRows(data,that.options.printSortColumn,that.options.printSortOrder);
|
122
|
-
var table=buildTable(data,that.options.columns
|
138
|
+
var table=buildTable(data,that.options.columns);
|
123
139
|
var newWin = window.open("");
|
124
140
|
newWin.document.write(that.options.printPageBuilder.call(this, table));
|
125
141
|
newWin.print();
|
@@ -141,8 +141,8 @@
|
|
141
141
|
}
|
142
142
|
}
|
143
143
|
|
144
|
-
for (var i = 0; i <
|
145
|
-
columnIndex =
|
144
|
+
for (var i = 0; i < this.length; i++ ) {
|
145
|
+
columnIndex = that.fieldsColumnsIndex[ths[i]];
|
146
146
|
if (columnIndex !== -1) {
|
147
147
|
that.columns[columnIndex].fieldIndex = i;
|
148
148
|
columns.push(that.columns[columnIndex]);
|
File without changes
|
@@ -1,9 +1,9 @@
|
|
1
1
|
/**
|
2
2
|
* @author: Jewway
|
3
|
-
* @version: v1.
|
3
|
+
* @version: v1.1.1
|
4
4
|
*/
|
5
5
|
|
6
|
-
!function ($) {
|
6
|
+
! function ($) {
|
7
7
|
'use strict';
|
8
8
|
|
9
9
|
function getCurrentHeader(that) {
|
@@ -15,23 +15,26 @@
|
|
15
15
|
return header;
|
16
16
|
}
|
17
17
|
|
18
|
-
function
|
19
|
-
return getCurrentHeader(that).find('[data-filter-field]');
|
20
|
-
}
|
21
|
-
|
22
|
-
function setFilterValues(that) {
|
23
|
-
var $filterElms = getFilterFields(that);
|
18
|
+
function initFilterValues(that) {
|
24
19
|
if (!$.isEmptyObject(that.filterColumnsPartial)) {
|
25
|
-
$
|
26
|
-
var $ele = $(ele),
|
27
|
-
field = $ele.attr('data-filter-field'),
|
28
|
-
value = that.filterColumnsPartial[field];
|
20
|
+
var $header = getCurrentHeader(that);
|
29
21
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
22
|
+
$.each(that.columns, function (idx, column) {
|
23
|
+
var value = that.filterColumnsPartial[column.field];
|
24
|
+
|
25
|
+
if (column.filter) {
|
26
|
+
if (column.filter.setFilterValue) {
|
27
|
+
var $filter = $header.find('[data-field=' + column.field + '] .filter');
|
28
|
+
column.filter.setFilterValue($filter, column.field, value);
|
29
|
+
} else {
|
30
|
+
var $ele = $header.find('[data-filter-field=' + column.field + ']');
|
31
|
+
switch (column.filter.type) {
|
32
|
+
case 'input':
|
33
|
+
$ele.val(value);
|
34
|
+
case 'select':
|
35
|
+
$ele.val(value).trigger('change');
|
36
|
+
}
|
37
|
+
}
|
35
38
|
}
|
36
39
|
});
|
37
40
|
}
|
@@ -39,89 +42,109 @@
|
|
39
42
|
|
40
43
|
function createFilter(that, header) {
|
41
44
|
var enableFilter = false,
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
isVisible,
|
46
|
+
html,
|
47
|
+
timeoutId = 0;
|
45
48
|
|
46
49
|
$.each(that.columns, function (i, column) {
|
47
50
|
isVisible = 'hidden';
|
48
|
-
html =
|
51
|
+
html = null;
|
49
52
|
|
50
53
|
if (!column.visible) {
|
51
54
|
return;
|
52
55
|
}
|
53
56
|
|
54
57
|
if (!column.filter) {
|
55
|
-
html
|
58
|
+
html = $('<div class="no-filter"></div>');
|
56
59
|
} else {
|
57
60
|
var filterClass = column.filter.class ? ' ' + column.filter.class : '';
|
58
|
-
html
|
61
|
+
html = $('<div style="margin: 0px 2px 2px 2px;" class="filter' + filterClass + '">');
|
59
62
|
|
60
63
|
if (column.searchable) {
|
61
64
|
enableFilter = true;
|
62
65
|
isVisible = 'visible'
|
63
66
|
}
|
64
67
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
if (column.filter.template) {
|
69
|
+
html.append(column.filter.template(that, column, isVisible));
|
70
|
+
} else {
|
71
|
+
var $filter = $(that.options.filterTemplate[column.filter.type.toLowerCase()](that, column, isVisible));
|
72
|
+
|
73
|
+
switch (column.filter.type) {
|
74
|
+
case 'input':
|
75
|
+
var cpLock = true;
|
76
|
+
$filter.off('compositionstart').on('compositionstart', function (event) {
|
77
|
+
cpLock = false;
|
78
|
+
});
|
79
|
+
|
80
|
+
$filter.off('compositionend').on('compositionend', function (event) {
|
81
|
+
cpLock = true;
|
82
|
+
var $input = $(this);
|
83
|
+
clearTimeout(timeoutId);
|
84
|
+
timeoutId = setTimeout(function () {
|
85
|
+
that.onColumnSearch(event, column.field, $input.val());
|
86
|
+
}, that.options.searchTimeOut);
|
87
|
+
});
|
88
|
+
|
89
|
+
$filter.off('keyup').on('keyup', function (event) {
|
90
|
+
if (cpLock) {
|
91
|
+
var $input = $(this);
|
92
|
+
clearTimeout(timeoutId);
|
93
|
+
timeoutId = setTimeout(function () {
|
94
|
+
that.onColumnSearch(event, column.field, $input.val());
|
95
|
+
}, that.options.searchTimeOut);
|
96
|
+
}
|
97
|
+
});
|
98
|
+
|
99
|
+
$filter.off('mouseup').on('mouseup', function (event) {
|
100
|
+
var $input = $(this),
|
101
|
+
oldValue = $input.val();
|
102
|
+
|
103
|
+
if (oldValue === "") {
|
104
|
+
return;
|
105
|
+
}
|
106
|
+
|
107
|
+
setTimeout(function () {
|
108
|
+
var newValue = $input.val();
|
109
|
+
|
110
|
+
if (newValue === "") {
|
111
|
+
clearTimeout(timeoutId);
|
112
|
+
timeoutId = setTimeout(function () {
|
113
|
+
that.onColumnSearch(event, column.field, newValue);
|
114
|
+
}, that.options.searchTimeOut);
|
115
|
+
}
|
116
|
+
}, 1);
|
117
|
+
});
|
118
|
+
break;
|
119
|
+
case 'select':
|
120
|
+
$filter.on('select2:select', function (event) {
|
121
|
+
that.onColumnSearch(event, column.field, $(this).val());
|
122
|
+
});
|
123
|
+
|
124
|
+
$filter.on("select2:unselecting", function (event) {
|
125
|
+
var $select2 = $(this);
|
126
|
+
event.preventDefault();
|
127
|
+
$select2.val(null).trigger('change');
|
128
|
+
that.searchText = undefined;
|
129
|
+
that.onColumnSearch(event, column.field, $select2.val());
|
130
|
+
});
|
131
|
+
break;
|
132
|
+
}
|
133
|
+
|
134
|
+
html.append($filter);
|
72
135
|
}
|
73
136
|
}
|
74
137
|
|
75
138
|
$.each(header.children().children(), function (i, tr) {
|
76
139
|
tr = $(tr);
|
77
140
|
if (tr.data('field') === column.field) {
|
78
|
-
tr.find('.fht-cell').append(html
|
141
|
+
tr.find('.fht-cell').append(html);
|
79
142
|
return false;
|
80
143
|
}
|
81
144
|
});
|
82
145
|
});
|
83
146
|
|
84
|
-
if (enableFilter) {
|
85
|
-
var $inputs = header.find('input'),
|
86
|
-
$selects = header.find('select');
|
87
|
-
|
88
|
-
|
89
|
-
if ($inputs.length > 0) {
|
90
|
-
$inputs.off('keyup').on('keyup', function (event) {
|
91
|
-
clearTimeout(timeoutId);
|
92
|
-
timeoutId = setTimeout(function () {
|
93
|
-
that.onColumnSearch(event);
|
94
|
-
}, that.options.searchTimeOut);
|
95
|
-
});
|
96
|
-
|
97
|
-
|
98
|
-
$inputs.off('mouseup').on('mouseup', function (event) {
|
99
|
-
var $input = $(this),
|
100
|
-
oldValue = $input.val();
|
101
|
-
|
102
|
-
if (oldValue === "") {
|
103
|
-
return;
|
104
|
-
}
|
105
|
-
|
106
|
-
setTimeout(function () {
|
107
|
-
var newValue = $input.val();
|
108
|
-
|
109
|
-
if (newValue === "") {
|
110
|
-
clearTimeout(timeoutId);
|
111
|
-
timeoutId = setTimeout(function () {
|
112
|
-
that.onColumnSearch(event);
|
113
|
-
}, that.options.searchTimeOut);
|
114
|
-
}
|
115
|
-
}, 1);
|
116
|
-
});
|
117
|
-
}
|
118
|
-
|
119
|
-
if ($selects.length > 0) {
|
120
|
-
$selects.on('select2:select', function (event) {
|
121
|
-
that.onColumnSearch(event);
|
122
|
-
});
|
123
|
-
}
|
124
|
-
} else {
|
147
|
+
if (!enableFilter) {
|
125
148
|
header.find('.filter').hide();
|
126
149
|
}
|
127
150
|
}
|
@@ -131,11 +154,9 @@
|
|
131
154
|
|
132
155
|
$.each(that.columns, function (idx, column) {
|
133
156
|
if (column.filter && column.filter.type === 'select') {
|
134
|
-
var $selectEle = $header.find('select[data-filter-field=' + column.field + ']');
|
157
|
+
var $selectEle = $header.find('select[data-filter-field="' + column.field + '"]');
|
135
158
|
|
136
159
|
if ($selectEle.length > 0 && !$selectEle.data().select2) {
|
137
|
-
column.filter.data.unshift("");
|
138
|
-
|
139
160
|
var select2Opts = {
|
140
161
|
placeholder: "",
|
141
162
|
allowClear: true,
|
@@ -144,12 +165,6 @@
|
|
144
165
|
};
|
145
166
|
|
146
167
|
$selectEle.select2(select2Opts);
|
147
|
-
$selectEle.on("select2:unselecting", function (event) {
|
148
|
-
event.preventDefault();
|
149
|
-
$selectEle.val(null).trigger('change');
|
150
|
-
that.searchText = undefined;
|
151
|
-
that.onColumnSearch(event);
|
152
|
-
});
|
153
168
|
}
|
154
169
|
}
|
155
170
|
});
|
@@ -157,23 +172,42 @@
|
|
157
172
|
|
158
173
|
$.extend($.fn.bootstrapTable.defaults, {
|
159
174
|
filter: false,
|
160
|
-
filterValues: {}
|
175
|
+
filterValues: {},
|
176
|
+
filterTemplate: {
|
177
|
+
input: function (instance, column, isVisible) {
|
178
|
+
return '<input type="text" class="form-control" data-filter-field="' + column.field + '" style="width: 100%; visibility:' + isVisible + '">';
|
179
|
+
},
|
180
|
+
select: function (instance, column, isVisible) {
|
181
|
+
return '<select data-filter-field="' + column.field + '" style="width: 100%; visibility:' + isVisible + '"></select>';
|
182
|
+
}
|
183
|
+
},
|
184
|
+
onColumnSearch: function (field, text) {
|
185
|
+
return false;
|
186
|
+
}
|
161
187
|
});
|
162
188
|
|
163
189
|
$.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
|
164
190
|
filter: undefined
|
165
191
|
});
|
166
192
|
|
193
|
+
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
194
|
+
'column-search.bs.table': 'onColumnSearch'
|
195
|
+
});
|
196
|
+
|
167
197
|
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
168
|
-
|
169
|
-
|
170
|
-
|
198
|
+
_init = BootstrapTable.prototype.init,
|
199
|
+
_initHeader = BootstrapTable.prototype.initHeader,
|
200
|
+
_initSearch = BootstrapTable.prototype.initSearch;
|
171
201
|
|
172
202
|
BootstrapTable.prototype.init = function () {
|
173
203
|
//Make sure that the filtercontrol option is set
|
174
204
|
if (this.options.filter) {
|
175
205
|
var that = this;
|
176
206
|
|
207
|
+
if (that.options.filterTemplate) {
|
208
|
+
that.options.filterTemplate = $.extend({}, $.fn.bootstrapTable.defaults.filterTemplate, that.options.filterTemplate);
|
209
|
+
}
|
210
|
+
|
177
211
|
if (!$.isEmptyObject(that.options.filterValues)) {
|
178
212
|
that.filterColumnsPartial = that.options.filterValues;
|
179
213
|
that.options.filterValues = {};
|
@@ -197,10 +231,10 @@
|
|
197
231
|
initSelect2(that);
|
198
232
|
clearTimeout(timeoutId);
|
199
233
|
timeoutId = setTimeout(function () {
|
200
|
-
|
234
|
+
initFilterValues(that);
|
201
235
|
}, that.options.searchTimeOut - 1000);
|
202
236
|
}).on('column-switch.bs.table', function (field, checked) {
|
203
|
-
|
237
|
+
initFilterValues(that);
|
204
238
|
});
|
205
239
|
}
|
206
240
|
|
@@ -215,23 +249,20 @@
|
|
215
249
|
};
|
216
250
|
|
217
251
|
BootstrapTable.prototype.initSearch = function () {
|
218
|
-
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
|
219
|
-
|
220
252
|
var that = this,
|
221
|
-
|
253
|
+
filterValues = that.filterColumnsPartial;
|
222
254
|
|
223
255
|
// Filter for client
|
224
256
|
if (that.options.sidePagination === 'client') {
|
225
257
|
this.data = $.grep(this.data, function (row, idx) {
|
226
258
|
for (var field in filterValues) {
|
227
|
-
var column = that.columns[
|
228
|
-
|
229
|
-
|
259
|
+
var column = that.columns[that.fieldsColumnsIndex[field]],
|
260
|
+
filterValue = filterValues[field].toLowerCase(),
|
261
|
+
rowValue = row[field];
|
230
262
|
|
231
263
|
rowValue = $.fn.bootstrapTable.utils.calculateObjectValue(
|
232
|
-
|
233
|
-
|
234
|
-
[rowValue, row, idx], rowValue);
|
264
|
+
that.header,
|
265
|
+
that.header.formatters[$.inArray(field, that.header.fields)], [rowValue, row, idx], rowValue);
|
235
266
|
|
236
267
|
if (column.filterStrictSearch) {
|
237
268
|
if (!($.inArray(field, that.header.fields) !== -1 &&
|
@@ -251,12 +282,11 @@
|
|
251
282
|
return true;
|
252
283
|
});
|
253
284
|
}
|
254
|
-
};
|
255
285
|
|
256
|
-
|
257
|
-
|
258
|
-
value = $.trim($(event.currentTarget).val());
|
286
|
+
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
|
287
|
+
};
|
259
288
|
|
289
|
+
BootstrapTable.prototype.onColumnSearch = function (event, field, value) {
|
260
290
|
if ($.isEmptyObject(this.filterColumnsPartial)) {
|
261
291
|
this.filterColumnsPartial = {};
|
262
292
|
}
|
@@ -269,14 +299,13 @@
|
|
269
299
|
|
270
300
|
this.options.pageNumber = 1;
|
271
301
|
this.onSearch(event);
|
302
|
+
this.trigger('column-search', field, value);
|
272
303
|
};
|
273
304
|
|
274
|
-
BootstrapTable.prototype.
|
305
|
+
BootstrapTable.prototype.setSelect2Data = function (field, data) {
|
275
306
|
var that = this,
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
data.unshift("");
|
307
|
+
$header = getCurrentHeader(that),
|
308
|
+
$selectEle = $header.find('select[data-filter-field=\"' + field + '\"]');
|
280
309
|
$selectEle.empty();
|
281
310
|
$selectEle.select2({
|
282
311
|
data: data,
|
@@ -297,7 +326,7 @@
|
|
297
326
|
this.filterColumnsPartial = values;
|
298
327
|
};
|
299
328
|
|
300
|
-
$.fn.bootstrapTable.methods.push('
|
329
|
+
$.fn.bootstrapTable.methods.push('setSelect2Data');
|
301
330
|
$.fn.bootstrapTable.methods.push('setFilterValues');
|
302
331
|
|
303
|
-
}(jQuery);
|
332
|
+
}(jQuery);
|