浏览代码

Support to disable radio or checkbox column by formatter.

zhixin 11 年之前
父节点
当前提交
4d1e1c2d09
共有 2 个文件被更改,包括 7 次插入3 次删除
  1. 1 0
      README.md
  2. 6 3
      src/bootstrap-table.js

+ 1 - 0
README.md

@@ -28,6 +28,7 @@ Bootstrap table displays data in a tabular format and offers rich support to rad
 - [x] Fix #135, #142: Search use formatted data.
 - [x] Verify search text before send queryParams.
 - [x] Fix #148: column events support namespace.
+- [x] Support to disable radio or checkbox column by formatter.
 
 ## Features
 

+ 6 - 3
src/bootstrap-table.js

@@ -871,8 +871,10 @@
                             sprintf(' name="%s"', that.options.selectItemName) +
                             sprintf(' type="%s"', type) +
                             sprintf(' value="%s"', item[that.options.idField]) +
-                            sprintf(' checked="%s"', value ? 'checked' : undefined) +
-                            sprintf(' %s', that.options.columns[j].checkboxEnabled ? undefined : 'disabled') +
+                            sprintf(' checked="%s"', +value === 1 ||
+                                (value && value.checked) ? 'checked' : undefined) +
+                            sprintf(' disabled="%s"', !that.options.columns[j].checkboxEnabled ||
+                                (value && value.disabled) ? 'disabled' : undefined) +
                             ' />',
                         '</td>'].join('');
                 } else {
@@ -937,7 +939,8 @@
                 $(this).prop('checked', true);
             }
 
-            var checkAll = that.$selectItem.length === that.$selectItem.filter(':checked').length,
+            var checkAll = that.$selectItem.filter(':enabled').length ===
+                    that.$selectItem.filter(':enabled').filter(':checked').length,
                 checked = $(this).prop('checked'),
                 row = that.data[$(this).data('index')];