From: Tiago Melo Date: Fri, 18 Jan 2019 12:19:19 +0000 (+0000) Subject: mgr/dashboard: Fix TableComponent when changing columns afterViewInit X-Git-Tag: v14.1.0~208^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f718524ee7ec09219f366f66a1f79711f044345b;p=ceph.git mgr/dashboard: Fix TableComponent when changing columns afterViewInit Angular was throwing an ExpressionChangedAfterItHasBeenCheckedError if you changed columns information right after the table was initiated. Signed-off-by: Tiago Melo --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts index 053b1fae7196..19ba5e427ee6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts @@ -1,5 +1,6 @@ import { AfterContentChecked, + ChangeDetectorRef, Component, EventEmitter, Input, @@ -159,7 +160,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O // table columns after the browser window has been resized. private currentWidth: number; - constructor(private ngZone: NgZone) {} + constructor(private ngZone: NgZone, private cdRef: ChangeDetectorRef) {} ngOnInit() { this._addTemplates(); @@ -451,6 +452,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O this.table.onColumnSort({ sorts: this.userConfig.sorts }); } this.table.recalculate(); + this.cdRef.detectChanges(); } createSortingDefinition(prop: TableColumnProp): SortPropDir[] {