Browse Source

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 years ago
parent
commit
3722fdd419
1 changed files with 17 additions and 7 deletions
  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('');
             };
         });
     };