@@ -32,7 +32,7 @@ import {
32
32
import { Subject } from 'rxjs' ;
33
33
import { takeUntil , first } from 'rxjs/operators' ;
34
34
import { IgxSelectionAPIService } from '../core/selection' ;
35
- import { cloneArray , isNavigationKey , CancelableEventArgs } from '../core/utils' ;
35
+ import { cloneArray , isNavigationKey , mergeObjects , CancelableEventArgs } from '../core/utils' ;
36
36
import { DataType , DataUtil } from '../data-operations/data-util' ;
37
37
import { FilteringLogic , IFilteringExpression } from '../data-operations/filtering-expression.interface' ;
38
38
import { IGroupByExpandState } from '../data-operations/groupby-expand-state.interface' ;
@@ -1633,7 +1633,7 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
1633
1633
/**
1634
1634
* Get transactions service for the grid.
1635
1635
*/
1636
- get transactions ( ) {
1636
+ get transactions ( ) : TransactionService < Transaction , State > {
1637
1637
return this . _transactions ;
1638
1638
}
1639
1639
@@ -2062,7 +2062,9 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
2062
2062
this . zone . run ( ( ) => {
2063
2063
this . cdr . detectChanges ( ) ;
2064
2064
this . verticalScrollContainer . onChunkLoad . emit ( this . verticalScrollContainer . state ) ;
2065
- this . changeRowEditingOverlayStateOnScroll ( this . rowInEditMode ) ;
2065
+ if ( this . rowEditable ) {
2066
+ this . changeRowEditingOverlayStateOnScroll ( this . rowInEditMode ) ;
2067
+ }
2066
2068
} ) ;
2067
2069
}
2068
2070
@@ -2097,7 +2099,7 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
2097
2099
constructor (
2098
2100
private gridAPI : GridBaseAPIService < IgxGridBaseComponent > ,
2099
2101
public selection : IgxSelectionAPIService ,
2100
- @Inject ( IgxGridTransaction ) private _transactions : TransactionService ,
2102
+ @Inject ( IgxGridTransaction ) protected _transactions : TransactionService < Transaction , State > ,
2101
2103
private elementRef : ElementRef ,
2102
2104
private zone : NgZone ,
2103
2105
@Inject ( DOCUMENT ) public document ,
@@ -2859,26 +2861,17 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
2859
2861
return ;
2860
2862
}
2861
2863
2864
+ // TODO: should we emit this when cascadeOnDelete is true for each row?!?!
2862
2865
this . onRowDeleted . emit ( { data : data [ index ] } ) ;
2863
2866
2864
- // if there is a row (index !== 0) delete it
2865
- // if there is a row in ADD or UPDATE state change it's state to DELETE
2866
- if ( index !== - 1 ) {
2867
- if ( this . transactions . enabled ) {
2868
- const transaction : Transaction = { id : rowId , type : TransactionType . DELETE , newValue : null } ;
2869
- this . transactions . add ( transaction , data [ index ] ) ;
2870
- } else {
2871
- this . deleteRowFromData ( rowId , index ) ;
2872
- }
2873
- } else {
2874
- this . transactions . add ( { id : rowId , type : TransactionType . DELETE , newValue : null } , state . recordRef ) ;
2875
- }
2876
-
2877
- if ( this . rowSelectable === true && this . selection . is_item_selected ( this . id , rowId ) ) {
2867
+ // first deselect row then delete it
2868
+ if ( this . rowSelectable && this . selection . is_item_selected ( this . id , rowId ) ) {
2878
2869
this . deselectRows ( [ rowId ] ) ;
2879
2870
} else {
2880
2871
this . checkHeaderCheckboxStatus ( ) ;
2881
2872
}
2873
+
2874
+ this . deleteRowFromData ( rowId , index ) ;
2882
2875
this . _pipeTrigger ++ ;
2883
2876
this . cdr . markForCheck ( ) ;
2884
2877
@@ -2892,7 +2885,19 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
2892
2885
* @hidden
2893
2886
*/
2894
2887
protected deleteRowFromData ( rowID : any , index : number ) {
2895
- this . data . splice ( index , 1 ) ;
2888
+ // if there is a row (index !== 0) delete it
2889
+ // if there is a row in ADD or UPDATE state change it's state to DELETE
2890
+ if ( index !== - 1 ) {
2891
+ if ( this . transactions . enabled ) {
2892
+ const transaction : Transaction = { id : rowID , type : TransactionType . DELETE , newValue : null } ;
2893
+ this . transactions . add ( transaction , this . data [ index ] ) ;
2894
+ } else {
2895
+ this . data . splice ( index , 1 ) ;
2896
+ }
2897
+ } else {
2898
+ const state : State = this . transactions . getState ( rowID ) ;
2899
+ this . transactions . add ( { id : rowID , type : TransactionType . DELETE , newValue : null } , state && state . recordRef ) ;
2900
+ }
2896
2901
}
2897
2902
2898
2903
/**
@@ -3542,7 +3547,7 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
3542
3547
if ( this . rowSelectable ) {
3543
3548
this . calcRowCheckboxWidth = this . headerCheckboxContainer . nativeElement . clientWidth ;
3544
3549
}
3545
- if ( this . rowEditable && ! this . rowEditingOverlay . collapsed ) {
3550
+ if ( this . rowEditable ) {
3546
3551
this . repositionRowEditingOverlay ( this . rowInEditMode ) ;
3547
3552
}
3548
3553
this . cdr . detectChanges ( ) ;
@@ -3842,7 +3847,7 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
3842
3847
* this.grid.selectRows([1,2,5], true);
3843
3848
* ```
3844
3849
* @param rowIDs
3845
- * @param clearCurrentSelection if true clears the curren selection
3850
+ * @param clearCurrentSelection if true clears the current selection
3846
3851
* @memberof IgxGridBaseComponent
3847
3852
*/
3848
3853
public selectRows ( rowIDs : any [ ] , clearCurrentSelection ?: boolean ) {
@@ -4319,18 +4324,18 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
4319
4324
this.nativeElement.focus();
4320
4325
} */
4321
4326
4322
- private changeRowEditingOverlayStateOnScroll ( row : IgxRowComponent < IgxGridBaseComponent > ) {
4323
- if ( ! this . rowEditable || this . rowEditingOverlay . collapsed ) {
4324
- return ;
4325
- }
4326
- if ( ! row ) {
4327
- this . toggleRowEditingOverlay ( false ) ;
4328
- } else {
4329
- this . repositionRowEditingOverlay ( row ) ;
4327
+ private changeRowEditingOverlayStateOnScroll ( row : IgxRowComponent < IgxGridBaseComponent > ) {
4328
+ if ( ! this . rowEditable || this . rowEditingOverlay . collapsed ) {
4329
+ return ;
4330
+ }
4331
+ if ( ! row ) {
4332
+ this . toggleRowEditingOverlay ( false ) ;
4333
+ } else {
4334
+ this . repositionRowEditingOverlay ( row ) ;
4335
+ }
4330
4336
}
4331
- }
4332
4337
4333
- /**
4338
+ /**
4334
4339
* @hidden
4335
4340
*/
4336
4341
public startRowEdit ( cell : {
@@ -4365,6 +4370,7 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
4365
4370
this . rowEditingOverlay . element . removeEventListener ( 'wheel' , this . rowEditingWheelHandler ) ;
4366
4371
this . rowEditPositioningStrategy . isTopInitialPosition = null ;
4367
4372
this . rowEditingOverlay . close ( ) ;
4373
+ this . rowEditingOverlay . element . parentElement . style . display = '' ;
4368
4374
}
4369
4375
4370
4376
/**
@@ -4383,9 +4389,15 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
4383
4389
* @hidden
4384
4390
*/
4385
4391
public repositionRowEditingOverlay ( row : IgxRowComponent < IgxGridBaseComponent > ) {
4386
- this . configureRowEditingOverlay ( row . rowID ) ;
4387
4392
if ( ! this . rowEditingOverlay . collapsed ) {
4388
- this . rowEditingOverlay . reposition ( ) ;
4393
+ const rowStyle = this . rowEditingOverlay . element . parentElement . style ;
4394
+ if ( row ) {
4395
+ rowStyle . display = '' ;
4396
+ this . configureRowEditingOverlay ( row . rowID ) ;
4397
+ this . rowEditingOverlay . reposition ( ) ;
4398
+ } else {
4399
+ rowStyle . display = 'none' ;
4400
+ }
4389
4401
}
4390
4402
}
4391
4403
@@ -4412,6 +4424,9 @@ export abstract class IgxGridBaseComponent implements OnInit, OnDestroy, AfterCo
4412
4424
return rowChanges ? Object . keys ( rowChanges ) . length : 0 ;
4413
4425
}
4414
4426
4427
+ protected writeToData ( rowIndex : number , value : any ) {
4428
+ mergeObjects ( this . data [ rowIndex ] , value ) ;
4429
+ }
4415
4430
/**
4416
4431
* TODO: Refactor
4417
4432
* @hidden
0 commit comments