Skip to content

Commit ce11568

Browse files
committed
Merge pull request wenzhixin#1383 from yenyen/filter-control-update
Fixe wenzhixin#1078 - the correct selectControl is updated when show/hide column
2 parents fdbd5d2 + 7093eed commit ce11568

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
}
@@ -395,7 +393,7 @@
395393
if (column.filterData === undefined || column.filterData.toLowerCase() === 'column') {
396394
var selectControl = $('.' + column.field);
397395
if (selectControl !== undefined && selectControl.length > 0) {
398-
if (selectControl.get(0).options.length === 0) {
396+
if (selectControl.get(selectControl.length - 1).options.length === 0) {
399397
//Added the default option
400398
addOptionToSelectControl(selectControl, '', '');
401399
}

0 commit comments

Comments
 (0)