Reputation: 1815
I need to get the original value of a row when someone starts to edit it.
Guess the beginEditCell method of http://ui-grid.info/docs/#/api/ui.grid.edit.service:uiGridEditService is doing exactly that. But I have no clue how to implement it.
This is how I call a function when the row is being saved.
$scope.users.onRegisterApi = function(gridApi){
// Set gridApi on scope
$scope.gridApi = gridApi;
// Call $scope.saveRow after finishing editing row
gridApi.rowEdit.on.saveRow($scope, $scope.saveRow);
};
So I assume .beginEditCell() needs to be called before .saveRow, but I don't get how.
Upvotes: 0
Views: 5303
Reputation: 8331
Then you should use this:
gridApi.edit.on.beginCellEdit($scope, function(rowEntity, colDef) {
//This alert just shows which info about the edit is available
alert('Column: ' + colDef.name + ' ID: ' + rowEntity.id + ' Name: ' + rowEntity.name + ' Age: ' + rowEntity.age)
});
The alert is just there to show you how to retrieve values from the row or the columnDefs.
Since the alert removes the focus from the input you should remove it.
Here is a Plunker
See also this more detailed answer about the afterCellEdit
event.
Hope this helps.
Upvotes: 2