Justin Dearing
Justin Dearing

Reputation: 14978

Stopping a particular ngGrid cell (not column) from being edited during ngGridEventStartCellEdit

I have an ngGrid with some individual cells (not columns) that I don't want to be edited. In my example plunk I want to not edit the cells where the row and column index are the same.

I tried preventDefault(), event.stopPropagation(), and an old fashioned return false; in my ngGridEventStartCellEdit but the cell still enters edit mode.

$scope.$on('ngGridEventStartCellEdit', function (event) {
    var row = event.targetScope.row.rowIndex;
    var col = event.targetScope.col.index - 1;
    if (row == col) {
        console.log("Not Gonna propagate");
        event.preventDefault();
        event.stopPropagation();
        return false;
    }
});

The console.log("Not Gonna propagate"); fires. What am I doing wrong?

Upvotes: 1

Views: 636

Answers (1)

Goodzilla
Goodzilla

Reputation: 1483

I tried using cellEditableCondition.

Here's the plunker with it. All you need is :

enableCellEdit: true,
cellEditableCondition: 'row.rowIndex !== col.index',

enableCellEdit has to be true for the editable condition to work.

Upvotes: 2

Related Questions