我用 ng-grid 设置了以下内容:
var gridData = {};
$scope.gridOptions = {
data: 'gridData',
enableCellEdit: true,
multiSelect: false,
columnDefs: [
{ field: 'testId', displayName: 'Test Id' },
{ field: 'name', displayName: 'Name', enableCellEdit: true, editableCellTemplate: cellEditableTemplate },
{ field: 'description', displayName: 'Description', enableCellEdit: true, editableCellTemplate: cellEditableTemplate },
{ field: '', cellTemplate: '<button ng-click="delete(row)">Delete</button>' }
]
};
和:
$scope.delete = function (row) {
row.entity.$deleteData({ testId: row.entity.testId });
}
这会向删除该行的服务器发送一条 HTTP 消息。但是,该行仍保留在网格中。我怎样才能做到这一点,以便单击一行上的删除按钮也会从 gridData 对象中删除一行?