From d0b08c89a3066b887509146d9e3a4058a64a0685 Mon Sep 17 00:00:00 2001 From: chintankavathia Date: Mon, 5 Feb 2024 01:18:41 +0530 Subject: [PATCH] fix(disable-row): allow disabling through side effects without mutating row data (#40) --- .../lib/components/body/body-row-wrapper.component.ts | 9 +++++---- .../src/lib/components/datatable.component.ts | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/projects/ngx-datatable/src/lib/components/body/body-row-wrapper.component.ts b/projects/ngx-datatable/src/lib/components/body/body-row-wrapper.component.ts index 7588d40d9..1c897ae4e 100644 --- a/projects/ngx-datatable/src/lib/components/body/body-row-wrapper.component.ts +++ b/projects/ngx-datatable/src/lib/components/body/body-row-wrapper.component.ts @@ -110,13 +110,14 @@ export class DataTableRowWrapperComponent implements DoCheck, OnInit { } ngDoCheck(): void { + if (this.disableCheck) { + const isRowDisabled = this.disableCheck(this.row); + this.disable$.next(isRowDisabled); + this.cd.markForCheck(); + } if (this.rowDiffer.diff(this.row)) { this.rowContext.row = this.row; this.groupContext.group = this.row; - if (this.disableCheck) { - const isRowDisabled = this.disableCheck(this.row); - this.disable$.next(isRowDisabled); - } this.cd.markForCheck(); } } diff --git a/projects/ngx-datatable/src/lib/components/datatable.component.ts b/projects/ngx-datatable/src/lib/components/datatable.component.ts index c6b71077b..ab619dc05 100644 --- a/projects/ngx-datatable/src/lib/components/datatable.component.ts +++ b/projects/ngx-datatable/src/lib/components/datatable.component.ts @@ -829,7 +829,7 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit, After * Lifecycle hook that is called when Angular dirty checks a directive. */ ngDoCheck(): void { - if (this.rowDiffer.diff(this.rows)) { + if (this.rowDiffer.diff(this.rows) || this.disableRowCheck) { if (!this.externalSorting) { this.sortInternalRows(); } else {