File tree Expand file tree Collapse file tree 4 files changed +26
-7
lines changed
projects/igniteui-angular/src/lib/grids
src/app/grid-updates-test Expand file tree Collapse file tree 4 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -4328,14 +4328,33 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
43284328 }
43294329
43304330 /**
4331- * Manually marks the `IgxGridComponent` for change detection.
4331+ * Triggers change detection for the `IgxGridComponent`.
4332+ * Calling markForCheck also triggers the grid pipes explicitly, resulting in all updates being processed.
4333+ * May degrade performance if used when not needed, or if misused:
4334+ * ```typescript
4335+ * // DON'Ts:
4336+ * // don't call markForCheck from inside a loop
4337+ * // don't call markForCheck when a primitive has changed
4338+ * grid.data.forEach(rec => {
4339+ * rec = newValue;
4340+ * grid.markForCheck();
4341+ * });
4342+ *
4343+ * // DOs
4344+ * // call markForCheck after updating a nested property
4345+ * grid.data.forEach(rec => {
4346+ * rec.nestedProp1.nestedProp2 = newValue;
4347+ * });
4348+ * grid.markForCheck();
4349+ * ```
43324350 *
43334351 * @example
43344352 * ```typescript
4335- * this.grid1 .markForCheck();
4353+ * grid .markForCheck();
43364354 * ```
43374355 */
43384356 public markForCheck ( ) {
4357+ this . _pipeTrigger ++ ;
43394358 this . cdr . detectChanges ( ) ;
43404359 }
43414360
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
168168 if ( document . body . contains ( grid . nativeElement ) ) {
169169 // Detect changes right away if the grid is visible
170170 grid . expandChildren = value ;
171- grid . markForCheck ( ) ;
171+ grid . cdr . detectChanges ( ) ;
172172 } else {
173173 // Else defer the detection on changes when the grid gets into view for performance.
174174 grid . updateOnRender = true ;
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ export class IgxRowDragDirective extends IgxDragDirective implements OnDestroy {
5858 }
5959 this . row . grid . dragRowID = this . row . rowID ;
6060 this . row . grid . rowDragging = true ;
61- this . row . grid . markForCheck ( ) ;
61+ this . row . grid . cdr . detectChanges ( ) ;
6262
6363 this . subscription$ = fromEvent ( this . row . grid . document . defaultView , 'keydown' ) . subscribe ( ( ev : KeyboardEvent ) => {
6464 if ( ev . key === KEYS . ESCAPE || ev . key === KEYS . ESCAPE_IE ) {
@@ -96,7 +96,7 @@ export class IgxRowDragDirective extends IgxDragDirective implements OnDestroy {
9696
9797 protected createGhost ( pageX , pageY ) {
9898 this . row . grid . endEdit ( false ) ;
99- this . row . grid . markForCheck ( ) ;
99+ this . row . grid . cdr . detectChanges ( ) ;
100100 this . ghostContext = {
101101 $implicit : this . row . rowData ,
102102 data : this . row . rowData ,
@@ -141,7 +141,7 @@ export class IgxRowDragDirective extends IgxDragDirective implements OnDestroy {
141141 this . onTransitionEnd ( null ) ;
142142 this . row . grid . dragRowID = null ;
143143 this . row . grid . rowDragging = false ;
144- this . row . grid . markForCheck ( ) ;
144+ this . row . grid . cdr . detectChanges ( ) ;
145145 this . _unsubscribe ( ) ;
146146 }
147147
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ export class GridUpdatesComponent implements OnInit {
5555 this . data [ itemIndex ] = { ...item } ;
5656
5757 // Needed because of OnPush strategy
58- this . grid . cdr . markForCheck ( ) ;
58+ this . grid . markForCheck ( ) ;
5959 }
6060}
6161
You can’t perform that action at this time.
0 commit comments