diff --git a/projects/ngx-datatable/src/lib/components/body/body.component.ts b/projects/ngx-datatable/src/lib/components/body/body.component.ts index 0a1b4ab85..03b97c7c4 100644 --- a/projects/ngx-datatable/src/lib/components/body/body.component.ts +++ b/projects/ngx-datatable/src/lib/components/body/body.component.ts @@ -269,8 +269,7 @@ export class DataTableBodyComponent implements OnInit, OnDestroy { @Input() set columns(val: any[]) { if (val !== this._columns) { this._columns = val; - const colsByPin = columnsByPin(val); - this.columnGroupWidths = columnGroupWidths(colsByPin, val); + this.updateColumnGroupWidths(); } } @@ -1012,4 +1011,9 @@ export class DataTableBodyComponent implements OnInit, OnDestroy { this._draggedRow = undefined; this._draggedRowElement = undefined; } + + updateColumnGroupWidths() { + const colsByPin = columnsByPin(this._columns); + this.columnGroupWidths = columnGroupWidths(colsByPin, this._columns); + } } diff --git a/projects/ngx-datatable/src/lib/components/datatable.component.ts b/projects/ngx-datatable/src/lib/components/datatable.component.ts index a56f73eec..02e410293 100644 --- a/projects/ngx-datatable/src/lib/components/datatable.component.ts +++ b/projects/ngx-datatable/src/lib/components/datatable.component.ts @@ -940,6 +940,11 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit, After adjustColumnWidths(columns, width); } + if (this.bodyComponent) { + this.bodyComponent.updateColumnGroupWidths(); + this.bodyComponent.cd.markForCheck(); + } + return columns; }