@@ -647,6 +647,46 @@ describe('IgxGrid - Cell Editing #grid', () => {
647
647
expect ( cell . editMode ) . toBe ( true ) ;
648
648
} ) ;
649
649
650
+ it ( `Should be able to update other cell in 'onCellEdit' event` , ( ) => {
651
+ grid . primaryKey = 'personNumber' ;
652
+ fixture . detectChanges ( ) ;
653
+
654
+ spyOn ( grid . onCellEdit , 'emit' ) . and . callThrough ( ) ;
655
+ grid . onCellEdit . subscribe ( ( e : IGridEditEventArgs ) => {
656
+ if ( e . cellID . columnID === 0 ) {
657
+ grid . updateCell ( 1 , e . rowID , 'age' ) ;
658
+ }
659
+ } ) ;
660
+
661
+ let cell = grid . getCellByColumn ( 0 , 'fullName' ) ;
662
+
663
+ UIInteractions . simulateClickAndSelectCellEvent ( cell ) ;
664
+ fixture . detectChanges ( ) ;
665
+
666
+ cell . nativeElement . dispatchEvent ( new MouseEvent ( 'dblclick' ) ) ;
667
+ fixture . detectChanges ( ) ;
668
+
669
+ expect ( cell . editMode ) . toBe ( true ) ;
670
+ let editTemplate = fixture . debugElement . query ( By . css ( 'input' ) ) ;
671
+ UIInteractions . sendInput ( editTemplate , 'New Name' ) ;
672
+ fixture . detectChanges ( ) ;
673
+
674
+ // press tab on edited cell
675
+ UIInteractions . triggerKeyDownWithBlur ( 'tab' , cell . nativeElement , true ) ;
676
+ fixture . detectChanges ( ) ;
677
+
678
+ expect ( grid . onCellEdit . emit ) . toHaveBeenCalledTimes ( 2 ) ;
679
+ cell = grid . getCellByColumn ( 0 , 'age' ) ;
680
+ expect ( cell . editMode ) . toBe ( true ) ;
681
+ expect ( cell . value ) . toEqual ( 1 ) ;
682
+ expect ( cell . editValue ) . toEqual ( 1 ) ;
683
+ editTemplate = fixture . debugElement . query ( By . css ( 'input' ) ) ;
684
+ expect ( editTemplate . nativeElement . value ) . toEqual ( '1' ) ;
685
+
686
+ cell = grid . getCellByColumn ( 0 , 'fullName' ) ;
687
+ expect ( cell . value ) . toEqual ( 'New Name' ) ;
688
+ } ) ;
689
+
650
690
it ( `Should properly emit 'onCellEditCancel' event` , ( ) => {
651
691
spyOn ( grid . onCellEditCancel , 'emit' ) . and . callThrough ( ) ;
652
692
const cell = grid . getCellByColumn ( 0 , 'fullName' ) ;
0 commit comments