浏览代码

Patch 3 - New Feature for Editable extension (#2038)

* Add conditional activation of editable by row

just define an option called "conditional" with content function(value, row, index). inside that function make the test to decide if the field is to be editable or not, if it is to be editable return "false" else return the html that should be used instead.
dreamerworks 9 年之前
父节点
当前提交
3722fdd419
共有 1 个文件被更改,包括 17 次插入7 次删除
  1. 17 7
      src/extensions/editable/bootstrap-table-editable.js

+ 17 - 7
src/extensions/editable/bootstrap-table-editable.js

@@ -69,14 +69,24 @@
                 $.each(editableOptions, function (key, value) {
                     editableDataMarkup.push(' ' + key + '="' + value + '"');
                 });
+                
+                var _dont_edit_formatter = false;
+                if (column.editable.hasOwnProperty('noeditFormatter')) {
+                    _dont_edit_formatter = column.editable.noeditFormatter(value, row, index);
+                }
+  
+                if (_dont_edit_formatter === false) {
+                    return ['<a href="javascript:void(0)"',
+                        ' data-name="' + column.field + '"',
+                        ' data-pk="' + row[that.options.idField] + '"',
+                        ' data-value="' + result + '"',
+                        editableDataMarkup.join(''),
+                        '>' + '</a>'
+                    ].join('');
+                } else {
+                    return _dont_edit_formatter;
+                }
 
-                return ['<a href="javascript:void(0)"',
-                    ' data-name="' + column.field + '"',
-                    ' data-pk="' + row[that.options.idField] + '"',
-                    ' data-value="' + result + '"',
-                    editableDataMarkup.join(''),
-                    '>' + '</a>'
-                ].join('');
             };
         });
     };