3

I have a editable table with extra rows .columnDefs. I added a grid api to table to get alert when something was change:

$scope.gridOptions.onRegisterApi = function (gridApi) {
        //set gridApi on scope
        $scope.gridApi = gridApi;
        gridApi.edit.on.afterCellEdit($scope, function (rowEntity, colDef, newValue, oldValue) {
            if (newValue !== oldValue) {
                alert('edited row id:' + rowEntity.id + ' Column:' + colDef.name + ' newValue:' + newValue + ' oldValue:' + oldValue);
            }
        });
    };

I don't know how to use it in columnDefs. I tried $scope.gridOptions.columnDefs.onRegisterApi = function (gridApi) {} But it isn't work. I have to get information what was changed in this sub rows.

2 Answers 2

2

$scope.gridOptions.columnDefs.onRegisterApi = function (gridApi) ... won't work, because onRegisterApi is not a property of columnDefs - it belongs directly in gridOptions.

If you want to only watch changes for a particular row / column or some such combination, filter by their name(s) in the handler function.

Sign up to request clarification or add additional context in comments.

Comments

-1

I dont see your problem, if you want to know what row, column changed , the code you have is right.

gridApi.edit.on.afterCellEdit($scope,function(rowEntity, colDef, newValue, oldValue){
        $scope.msg.lastCellEdited = 'edited row id:' + rowEntity.id + ' Column:' + colDef.name + ' newValue:' + newValue + ' oldValue:' + oldValue ;
        console.log('edited row id:' + rowEntity.id + ' Column:' + colDef.name + ' newValue:' + newValue + ' oldValue:' + oldValue);
        $scope.$apply();
      });

The rowEntity is the data row which was modifier. ColDef is the exact column which was edited.

Try it again or explain more in your question.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.