浏览代码

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 年之前
父节点
当前提交
eaed7daad1
共有 2 个文件被更改,包括 6 次插入1 次删除
  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
 
         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)
 
         text = [

+ 4 - 0
src/utils/index.js

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