Table columns auto fit the the content width

UI Components for Angular
Post Reply
Arudian
Posts: 3
Joined: 02 Oct 2019, 13:47

07 Oct 2019, 13:18

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.

artem.nikitin
Posts: 3
Joined: 06 Oct 2019, 17:43

09 Oct 2019, 22:13

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">

Arudian
Posts: 3
Joined: 02 Oct 2019, 13:47

16 Oct 2019, 13:27

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;

 }

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest