Skip to content

Commit a1ae5b4

Browse files
authored
Merge branch '10.2.x' into gedinakova/fix-9465-10.2
2 parents d69235d + ce9b1fd commit a1ae5b4

File tree

5 files changed

+45
-9
lines changed

5 files changed

+45
-9
lines changed

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4110,13 +4110,33 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
41104110
}
41114111

41124112
/**
4113-
* Manually marks the `IgxGridComponent` for change detection.
4113+
* Triggers change detection for the `IgxGridComponent`.
4114+
* Calling markForCheck also triggers the grid pipes explicitly, resulting in all updates being processed.
4115+
* May degrade performance if used when not needed, or if misused:
4116+
* ```typescript
4117+
* // DON'Ts:
4118+
* // don't call markForCheck from inside a loop
4119+
* // don't call markForCheck when a primitive has changed
4120+
* grid.data.forEach(rec => {
4121+
* rec = newValue;
4122+
* grid.markForCheck();
4123+
* });
4124+
*
4125+
* // DOs
4126+
* // call markForCheck after updating a nested property
4127+
* grid.data.forEach(rec => {
4128+
* rec.nestedProp1.nestedProp2 = newValue;
4129+
* });
4130+
* grid.markForCheck();
4131+
* ```
4132+
*
41144133
* @example
41154134
* ```typescript
4116-
* this.grid1.markForCheck();
4135+
* grid.markForCheck();
41174136
* ```
41184137
*/
41194138
public markForCheck() {
4139+
this._pipeTrigger++;
41204140
this.cdr.detectChanges();
41214141
}
41224142

projects/igniteui-angular/src/lib/grids/hierarchical-grid/row-island.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
9292
if (document.body.contains(grid.nativeElement)) {
9393
// Detect changes right away if the grid is visible
9494
grid.expandChildren = value;
95-
grid.markForCheck();
95+
grid.cdr.detectChanges();
9696
} else {
9797
// Else defer the detection on changes when the grid gets into view for performance.
9898
grid.updateOnRender = true;

projects/igniteui-angular/src/lib/grids/row-drag.directive.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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(true);
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

src/app/grid-filter-template/grid-filter-template.sample.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
tabindex="0"
3939
placeholder="Filter..."
4040
autocomplete="off"
41-
(input)="onInput(input, column)"/>
42-
<igx-suffix *ngIf="input.value || input.value === 0" (click)="clearInput(input, column)" tabindex="0">
41+
(input)="onInput(input, column)"
42+
(keydown)="onKeyDown($event)"/>
43+
<igx-suffix *ngIf="input.value" (click)="clearInput(input, column)" tabindex="0">
4344
<igx-icon>clear</igx-icon>
4445
</igx-suffix>
4546
</igx-input-group>

src/app/grid-filter-template/grid-filter-template.sample.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,22 +490,37 @@ export class GridFilterTemplateSampleComponent implements OnInit {
490490

491491
public onInput(input: any, column: IgxColumnComponent) {
492492
let operand = null;
493+
let value = input.value;
494+
495+
if (value === '') {
496+
this.grid1.clearFilter(column.field);
497+
return;
498+
}
499+
493500
switch (column.dataType) {
494501
case DataType.Number:
502+
value = Number.parseInt(value, 10);
495503
operand = IgxNumberFilteringOperand.instance().condition('equals');
496504
break;
497505
case DataType.Date:
506+
value = new Date(value);
498507
operand = IgxDateFilteringOperand.instance().condition('equals');
499508
break;
500509
default:
501510
operand = IgxStringFilteringOperand.instance().condition('contains');
502511
break;
503512
}
504-
this.grid1.filter(column.field, input.value, operand, column.filteringIgnoreCase);
513+
514+
this.grid1.filter(column.field, value, operand, column.filteringIgnoreCase);
505515
}
506516

507517
public clearInput(input: any, column: any) {
508518
input.value = null;
509519
this.grid1.clearFilter(column.field);
510520
}
521+
522+
public onKeyDown(event: KeyboardEvent) {
523+
event.stopImmediatePropagation();
524+
}
525+
511526
}

0 commit comments

Comments
 (0)