Skip to content

Commit

Permalink
Fix check containerViewChild for undefined in saveColumnWidths
Browse files Browse the repository at this point in the history
  • Loading branch information
Kisters-BS committed Sep 30, 2024
1 parent d6c7ffc commit ccbef9d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/app/components/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2908,7 +2908,13 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable

saveColumnWidths(state: any) {
let widths: any[] = [];
let headers = DomHandler.find(this.containerViewChild?.nativeElement, '.p-datatable-thead > tr > th');
let headers = [];
const container = this.containerViewChild?.nativeElement;

if (container) {
headers = DomHandler.find(container, '.p-datatable-thead > tr > th');
}

headers.forEach((header) => widths.push(DomHandler.getOuterWidth(header)));
state.columnWidths = widths.join(',');

Expand Down

0 comments on commit ccbef9d

Please sign in to comment.