我有一个包含额外行 .columnDefs 的可编辑表。我在表中添加了一个网格 api,以便在发生更改时获得警报:
$scope.gridOptions.onRegisterApi = function (gridApi) {
//set gridApi on scope
$scope.gridApi = gridApi;
gridApi.edit.on.afterCellEdit($scope, function (rowEntity, colDef, newValue, oldValue) {
if (newValue !== oldValue) {
alert('edited row id:' + rowEntity.id + ' Column:' + colDef.name + ' newValue:' + newValue + ' oldValue:' + oldValue);
}
});
};
我不知道如何在 columnDefs 中使用它。我尝试了 $scope.gridOptions.columnDefs.onRegisterApi = function (gridApi) {}
但这是行不通的。我必须了解此子行中更改的内容。
最佳答案
$scope.gridOptions.columnDefs.onRegisterApi = function (gridApi) ...
将不起作用,因为 onRegisterApi
不是 columnDefs< 的属性
- 它直接属于 gridOptions
。
如果您只想查看特定行/列或某些此类组合的更改,请在处理函数中按它们的名称进行过滤。
关于angularjs - angular ui-grid 如何在 gridOptions 中使用 onRegisterApi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30192218/