]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Fix TableComponent when changing columns afterViewInit
authorTiago Melo <tmelo@suse.com>
Fri, 18 Jan 2019 12:19:19 +0000 (12:19 +0000)
committerTiago Melo <tmelo@suse.com>
Tue, 5 Feb 2019 12:02:33 +0000 (12:02 +0000)
Angular was throwing an ExpressionChangedAfterItHasBeenCheckedError if you
changed columns information right after the table was initiated.

Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts

index 053b1fae7196be9f2c9e644caf68fc46c5c62f64..19ba5e427ee6aacbf772d9122743870635378364 100644 (file)
@@ -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[] {