在角度 ui-grid 中检测单元格编辑 [英] detect cell edit in angular ui-grid

查看:25
本文介绍了在角度 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆