在角度ui-grid中检测单元格编辑 [英] detect cell edit in angular ui-grid
本文介绍了在角度ui-grid中检测单元格编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试检测单元格编辑,但以下代码未获取事件. 我使用名称":"angular-ui-grid",版本":"3.0.0-rc.14", 我必须定义一些配置来获取事件吗?
I try to detect cell edit but the following code does not get event. I use "name": "angular-ui-grid", "version": "3.0.0-rc.14", Do I have to define some configuration to get events?
$scope.$on('ngGridEventEndCellEdit', function(data) {
推荐答案
我将默认行模板更新为如下所示
I updated the default row template to look like below
rowTemplate: '<div ng-class="{\'row-changed\':row.entity.State==\'changed\'}" ng-click="grid.appScope.fnOne(row)" ng-repeat="col in colContainer.renderedColumns track by col.colDef.name" class="ui-grid-cell" ui-grid-cell></div>',
然后在onRegisterApi中
And then in onRegisterApi
onRegisterApi: function( gridApi ) {
$scope.gridApi = gridApi;
$scope.gridApi.edit.on.afterCellEdit($scope,function(rowEntity, colDef, newValue, oldValue){
if(newValue != oldValue)
rowEntity.State = "changed";
})
}
如果实体的状态为更改",则该行现在将获得行更改"类.
The row will now get the class "row-changed" if the entity has the State "changed".
如果单元格变回其原始值,您可能要添加一些额外的检查,但这是另一个问题.
You might want to add some extra checks if the cell gets changed back to its original value, but that's another issue.
这篇关于在角度ui-grid中检测单元格编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文