Allow enabling/disabling of the Edit button of a sub-node collection grid.

This commit is contained in:
Khushboo Vashi
2016-03-10 12:03:33 +00:00
committed by Dave Page
parent d32e861a47
commit 3b03c17f2b

View File

@@ -1098,11 +1098,13 @@
if (data.disabled == false && data.canEdit) { if (data.disabled == false && data.canEdit) {
var editCell = Backgrid.Extension.ObjectCell.extend({ var editCell = Backgrid.Extension.ObjectCell.extend({
schema: gridSchema.schema schema: gridSchema.schema
}); }),
canEdit = self.field.has('canEdit') &&
self.field.get('canEdit') || true;
gridSchema.columns.unshift({ gridSchema.columns.unshift({
name: "pg-backform-edit", label: "", cell : editCell, name: "pg-backform-edit", label: "", cell : editCell,
cell_priority: -2 cell_priority: -2, editable: canEdit
}); });
} }
@@ -1140,7 +1142,7 @@
grid.insertRow({}); grid.insertRow({});
var newRow = $(grid.body.rows[collection.length - 1].$el); var newRow = $(grid.body.rows[collection.length - 1].$el);
newRow.attr("class", "new").click(function(e) { newRow.attr("class", "new").click(function(e) {
$(this).attr("class", ""); $(this).attr("class", "editable");
}); });
$(newRow).pgMakeVisible('backform-tab'); $(newRow).pgMakeVisible('backform-tab');
return false; return false;