'ag-grid how to delete row
I am using ag-grid v1.7 and angularJS 1.6.1 Grid column definition -
var columnDefs: [
{headerName: 'Col A', field: 'a'}
{headerName: 'Col B', field: 'b'}
{headerName: 'Delete', field: 'delete', cellRenderer : function(params){
return '<a ng-click="deleteRow(' + params.value + '" class="btn-link">Delete</a>
}}
];
Here I want to delete the current row on click of Delete button. Here row is not selected. I found some code which say's use it as below, but it is not working (row.entity - is not getting replaced with actual row data).-
var columnDefs: [
{headerName: 'Col A', field: 'a'}
{headerName: 'Col B', field: 'b'}
{headerName: 'Delete', field: 'delete', cellRenderer : function(params){
return '<a ng-click="deleteRow(row.entity,' + params.value + '" class="btn-link">Delete</a>
}}
];
Solution 1:[1]
try below code--
var columnDefs: [
{headerName: 'Col A', field: 'a'}
{headerName: 'Col B', field: 'b'}
{headerName: 'Delete', field: 'delete', cellRenderer : function(params){
return '<i class="icon-trash cell-btn-remove" title="Delete this record" ng-click="deleteRecord(data,'+params.node.id+')">'
}}
];
$scope.deleteRecord = function(params,rowIndex){
//delete from map using index
// map.splice(1,rowIndex);
$scope.gridOptions.api.setRowData(map);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | v0d1ch |
