Browse Source

Methods to check/uncheck rows by values - parameter unification

Parameter used in methods to check/uncheck rows by values now looks the same like in "remove" method:
e.g. {field:"field_name", values:["value1","value2","value3"]}
macias3 11 years ago
parent
commit
27980f78bf
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/bootstrap-table.js

+ 5 - 2
src/bootstrap-table.js

@@ -1548,10 +1548,13 @@
     };
     
     BootstrapTable.prototype.checkBy_ = function (checked, obj) {
+        if (!obj.hasOwnProperty("field") || !obj.hasOwnProperty("values")) {
+            return;
+        }
+        
         var that = this;
-        var is_array = $.isArray(obj.value);
         $.each(this.data, function (index, row) {
-            if(is_array ? $.inArray(row[obj.field], obj.value) != -1 : row[obj.field] == obj.value) {
+            if($.inArray(row[obj.field], obj.values) != -1) {
                 that.$selectItem.filter(sprintf('[data-index="%s"]', index)).prop('checked', checked);
                 row[that.header.stateField] = checked;
                 that.trigger(checked ? 'check' : 'uncheck', row);