8000 Fixe #1078 - the correct selectControl is updated when show/hide column · coderabsolute/bootstrap-table@7093eed · GitHub
[go: up one dir, main page]

Skip to content

Commit 7093eed

Browse files
author
Aurélien Thévoz
committed
Fixe wenzhixin#1078 - the correct selectControl is updated when show/hide column
1 parent f65c2de commit 7093eed

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/extensions/filter-control/bootstrap-table-filter-control.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
};
6363

6464
var addOptionToSelectControl = function (selectControl, value, text) {
65-
//selectControl = $(selectControl.get(0));
65+
selectControl = $(selectControl.get(selectControl.length - 1));
6666
if (existsOptionInSelectControl(selectControl, value)) {
6767
selectControl.append($("<option></option>")
6868
.attr("value", value)
@@ -87,11 +87,9 @@
8787
};
8888

8989
var existsOptionInSelectControl = function (selectControl, value) {
90-
var options = selectControl.get(0).options,
91-
iOpt = 0;
92-
93-
for (; iOpt < options.length; iOpt++) {
94-
if (options[iOpt].value === value) {
90+
var options = selectControl.get(selectControl.length - 1).options;
91+
for (var i = 0; i < options.length; i++) {
92+
if (options[i].value === value) {
9593
//The value is nor valid to add
9694
return false;
9795
}
@@ -375,7 +373,7 @@
375373
if (column.filterData === undefined || column.filterData.toLowerCase() === 'column') {
376374
var selectControl = $('.' + column.field);
377375
if (selectControl !== undefined && selectControl.length > 0) {
378-
if (selectControl.get(0).options.length === 0) {
376+
if (selectControl.get(selectControl.length - 1).options.length === 0) {
379377
//Added the default option
380378
addOptionToSelectControl(selectControl, '', '');
381379
}

0 commit comments

Comments
 (0)
0