Skip to content

Commit

Permalink
Merge pull request #16460 from Kisters-BS/fix/containerUndefined
Browse files Browse the repository at this point in the history
Fix check containerViewChild for undefined in saveColumnWidths
  • Loading branch information
cetincakiroglu authored Oct 11, 2024
2 parents c2f2d55 + ccbef9d commit bc6952c
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 bc6952c

Please sign in to comment.