Browse Source

The checked property is ignored on checkbox columns where the field has a value (#5239)

* Checked property ignored

The checked property is ignored if the field has a value.
Greg 5 years ago
parent
commit
eaed7daad1
2 changed files with 6 additions and 1 deletions
  1. 2 1
      src/bootstrap-table.js
  2. 4 0
      src/utils/index.js

+ 2 - 1
src/bootstrap-table.js

@@ -1474,7 +1474,8 @@ class BootstrapTable {
         type = column.radio ? 'radio' : type
         type = column.radio ? 'radio' : type
 
 
         const c = column['class'] || ''
         const c = column['class'] || ''
-        const isChecked = (value === true || value_ || (value && value.checked)) && value !== false
+        const isChecked = Utils.isObject(value) && value.hasOwnProperty('checked') ?
+          value.checked : (value === true || value_) && value !== false
         const isDisabled = !column.checkboxEnabled || (value && value.disabled)
         const isDisabled = !column.checkboxEnabled || (value && value.disabled)
 
 
         text = [
         text = [

+ 4 - 0
src/utils/index.js

@@ -24,6 +24,10 @@ export default {
     return flag ? str : ''
     return flag ? str : ''
   },
   },
 
 
+  isObject (val) {
+    return val instanceof Object && !Array.isArray(val)
+  },
+
   isEmptyObject (obj = {}) {
   isEmptyObject (obj = {}) {
     return Object.entries(obj).length === 0 && obj.constructor === Object
     return Object.entries(obj).length === 0 && obj.constructor === Object
   },
   },