[英]How do I detect cell change in ng-grid NOT just an end to ng-grid event?
I have an editable ng-grid in my web application. 我的Web应用程序中有一个可编辑的ng-grid。 The grid functions make my life easy and are truly great but I've noticed one minor problem that I don't know how to work around gracefully.
网格功能使我的生活变得轻松并且确实很棒,但是我注意到一个小问题,我不知道如何优雅地解决。
Namely, I want to detect when a user has made changes to the grid. 即,我想检测用户何时对网格进行了更改。 Right now, I use...
现在,我用...
$scope.$on('ngGridEventEndCellEdit', function(evt) {
$ scope。$ on('ngGridEventEndCellEdit',function(evt){
//function goes here!
});
});
...this works, kind of. ...这很有效
The problem is this event is triggered even when the user has NOT made a change to the cell but has only clicked/tabbed into/out-of it. 问题在于,即使用户未对单元格进行更改,而仅单击/跳入/跳出该单元格,也会触发此事件。 I don't want to have to compare each field in the row from the before and after to detect if a change has been made -- is there a better way?
我不想从前后比较行中的每个字段以检测是否已进行更改-是否有更好的方法?
Thanks! 谢谢!
If you just want to detect when the user starts editing a cell : 如果只想检测用户何时开始编辑单元格:
$scope.$on('ngGridEventStartCellEdit', function(evt) {
//function goes here!
});
(note the Start instead of End ) (注意开始而不是结束 )
Otherwise, ForgetfulFellow's link should have your solution : 否则,ForgetfulFellow的链接应该具有您的解决方案:
cellEditableTemplate = "<input ng-class=\"'colt' + col.index\" ng-input=\"COL_FIELD\" ng-model=\"COL_FIELD\" ng-change=\"updateEntity(row.entity)\"/>"
The ng-change will be called on each keystroke. 每次按键时都会调用ng-change。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.