浏览代码

Imporve the filter-control extension

Dennis Hernández 10 年之前
父节点
当前提交
eed49e301e
共有 1 个文件被更改,包括 12 次插入21 次删除
  1. 12 21
      src/extensions/filter-control/bootstrap-table-filter-control.js

+ 12 - 21
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -158,39 +158,30 @@
                     that.header.formatters[j], [value, item, i], value);
 
                 if ((!column.checkbox) || (!column.radio)) {
-                    if (column.filterControl !== undefined && column.filterControl.toLowerCase() === 'select'
-                        && column.searchable) {
-
+                    if (column.filterControl !== undefined && column.filterControl.toLowerCase() === 'select' && column.searchable) {
                         var selectControl = $('.' + column.field),
                             iOpt = 0,
-                            exitsOpt = false,
+                            existsOpt = 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", '').text(''));
+                            }
+
+                            for (; iOpt < options.length; iOpt++) {
+                                if (options[iOpt].value === value) {
+                                    existsOpt = true;
+                                    break;
+                                }
+                            }
 
+                            if (!existsOpt) {
                                 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));
-                                }
                             }
                         }
                     }