ソースを参照

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) {
                 $.each(editableOptions, function (key, value) {
                     editableDataMarkup.push(' ' + 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('');
             };
             };
         });
         });
     };
     };