浏览代码

added ability to handle booleans and simplify code (#4241)

Dustin U 6 年之前
父节点
当前提交
153aa66075
共有 1 个文件被更改,包括 4 次插入16 次删除
  1. 4 16
      src/extensions/filter-control/bootstrap-table-filter-control.js

+ 4 - 16
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -733,25 +733,13 @@
               }
 
               if ($.inArray(key, that.header.fields) !== -1) {
-                if (typeof value === 'string' || typeof value === 'number') {
+                if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
                   if (thisColumn.filterStrictSearch) {
-                    if (value.toString().toLowerCase() === fval.toString().toLowerCase()) {
-                      itemIsExpected.push(true)
-                    } else {
-                      itemIsExpected.push(false)
-                    }
+                    itemIsExpected.push(value.toString().toLowerCase() === fval.toString().toLowerCase())
                   } else if (thisColumn.filterStartsWithSearch) {
-                    if ((`${value}`).toLowerCase().indexOf(fval) === 0) {
-                      itemIsExpected.push(true)
-                    } else {
-                      itemIsExpected.push(false)
-                    }
+                    itemIsExpected.push((`${value}`).toLowerCase().indexOf(fval) === 0)
                   } else {
-                    if ((`${value}`).toLowerCase().includes(fval)) {
-                      itemIsExpected.push(true)
-                    } else {
-                      itemIsExpected.push(false)
-                    }
+                    itemIsExpected.push((`${value}`).toLowerCase().includes(fval))
                   }
                 }
               }