I have been looking for an example on how to implement a button to remove a selected row, but I couldn\'t find anything useful so far.
Can anyone please give me a hint?
Previous answer to this question won't work once the array has been sorted because the row.index changes based on the way the array has been sorted but the original data in the array remains in it's original index. We must find the correct index in the data array in order to remove the correct row. The row contains a reference to the original data in row.entity so we can use indexOf to find the correct index.
$scope.actionTemplate = '';
$scope.delete = function($event) {
$event.stopPropagation(); //keep the row from being selected
$scope.data.selectAll(false); //remove all selections: necessary for issues with the selection array
var index = $scope.data.indexOf(this.row.entity); //get the correct index to splice
$scope.metrics.splice(index, 1); //remove the element
};
Edit: The original solution may have worked at the time but ng-grid has since been updated and it no longer works.