Page 1 of 1

Table columns auto fit the the content width

Posted: 07 Oct 2019, 13:18
by Arudian
Hi,

Just as in the title, I am wondering if there is some kind of autofit feature for tables. I would like to have column width match the content, and not use predefined width for all columns.

Re: Table columns auto fit the the content width

Posted: 09 Oct 2019, 22:13
by artem.nikitin
Hi,

You can start with autoLayout set to true, because primeng's table has fixed table-layout by default. Table width is 100% by default so it may be enough for your case

Code: Select all

<p-table [columns]="cols" [value]="rows" [autoLayout]="true">

Re: Table columns auto fit the the content width

Posted: 16 Oct 2019, 13:27
by Arudian
Thank you, but it wasn't compatible with some othere datatable features so i went with custom column width with overlay for the longer texts :)

Code: Select all

 #Table td {
    white-space:nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
    font-size: 12px;

 }