Currently, I am facing an issue while trying to incorporate both column resize functionality and sticky header in my table. Interestingly, the sticky header feature works perfectly fine when used alone without the column resize. However, when I attempt to implement both, the column resize functionality works properly but the sticky header fails to function.
To achieve the sticky header effect, I applied the following CSS styles provided by primeng:
:host ::ng-deep .ui-table .ui-table-thead > tr > th {
position: -webkit-sticky;
position: sticky;
top: 70px;
}
@media screen and (max-width: 64em) {
:host ::ng-deep .ui-table .ui-table-thead > tr > th {
top: 100px;
}
}
For enabling column resize, I utilized the code snippet [resizableColumns]="true"
and pResizableColumn
:
<p-table [columns]="cols" [value]="cars1" [resizableColumns]="true">
...
<th *ngFor="let col of columns" pResizableColumn>
Interestingly, upon removing the resizbleColumns
attribute and the pResizableColumn
directive, the sticky header functions correctly. How can I ensure that both features work harmoniously together? You can also find a working example on StackBlitz and see the Demo.