ag-grid how to delete row

9.4k Views Asked by At

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>
    }}
  ];
1

There are 1 best solutions below

0
On

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);
 }