浏览代码

Added validation in order to avoid incorrect calls

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

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

@@ -436,21 +436,23 @@
     };
 
     BootstrapTable.prototype.clearFilterControl = function () {
-        $.each(this.options.values, function (i, item) {
-            item.value = '';
-        });
+        if (this.options.filterControl && this.options.filterShowClear) {
+            $.each(this.options.values, function (i, item) {
+                item.value = '';
+            });
 
-        setValues(this);
+            setValues(this);
 
-        var controls = getCurrentHeader(this).find(getCurrentSearchControls(this)),
-            timeoutId = 0;
+            var controls = getCurrentHeader(this).find(getCurrentSearchControls(this)),
+                timeoutId = 0;
 
-        if (controls.length > 0) {
-            this.filterColumnsPartial = {};
-            clearTimeout(timeoutId);
-            timeoutId = setTimeout(function () {
-                $(controls[0]).trigger(controls[0].tagName === 'INPUT' ? 'keyup' : 'change');
-            }, this.options.searchTimeOut);
+            if (controls.length > 0) {
+                this.filterColumnsPartial = {};
+                clearTimeout(timeoutId);
+                timeoutId = setTimeout(function () {
+                    $(controls[0]).trigger(controls[0].tagName === 'INPUT' ? 'keyup' : 'change');
+                }, this.options.searchTimeOut);
+            }
         }
     };
 }(jQuery);