我正在使用ag-grid v1.7和angularJS 1.6.1 网格列定义 -
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>
}}
];
这里我想删除单击“删除”按钮时的当前行。这里没有选择行。我找到了一些代码,说如下所示使用它,但它不起作用(row.entity - 没有被实际的行数据替换).-
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>
}}
];
答案 0 :(得分:0)
尝试以下代码 -
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);
}