PDA

View Full Version : Make row not editable in EditorGridPanel based on record data?



drian
12 May 2011, 9:54 AM
Hi guys,


Could some one point me into the right direction please?

I have an EditorGridPanel with an editable column. How can i disable the editing on a certain row?

thanks.

EDIT:

Boy I need a good sleep... missed the beforeedit event.

kembuco
12 May 2011, 10:13 AM
So, the way I see it you have two options:

1) Make use of isCellEditable on the column model:

var colModel = new Ext.grid.ColumnModel({
columns: [...],
isCellEditable: function(col, row) {
var record = store.getAt(row);
if (record.get('readonly')) { // replace with your condition
return false;
}
return Ext.grid.ColumnModel.prototype.isCellEditable.call(this, col, row);
}
});

2) Make use of the "beforeedit" event on EditorGridPanel:

{
xtype: "editorgrid",
listeners: {
beforeedit: function(e) {
if (e.record.get("something") != "whatwerelookingfor") {
return false;
}

return true;
}
}
}

drian
12 May 2011, 9:13 PM
yep, thanks.

Already solved this 5 minutes after posting the topic. Went with the beforeedit event. Btw, you don't need to use return true because the if statement works in a synchronous way.