I have a p-table defined with [scrollable]="true"
<p-table
*ngIf="!loading"
[value]="data"
[resizableColumns]="true"
[reorderableColumns]="true"
[columns]="columns"
[autoLayout]="true" <---
[scrollable]="true" <---
scrollHeight="75vh"
>
The [scrollable]
changes the table layout from display: table-cell
to display:flex
and thus the [autoLayout]
is now ignored.
I have tried setting the styles here to percentage widths (i.e. 10%/10%/80%) but it has no effect with the flex
display table.
<th
*ngFor="let col of columns"
pSortableColumn="{{ col.field }}"
pReorderableColumn
pResizableColumn
[ngStyle]="{'width': col.width}" <---
>
I see there is a PrimeNG issue commenting on this, but are there any workarounds I can use to get set column widths when using [scrollable]
?
https://github.com/primefaces/primeng/issues/5510#issuecomment-432155295
style="flex: 0 0 320px;"
is doing a lot of the heavy lifting, from the MDN flex page: /* Three values: flex-grow | flex-shrink | flex-basis */ - flex: 2 2 10%; I think that explains a lot of what you need to know about the code above (that has no explanation). – Ere