Create dynamic columns but the first column should be static

UI Components for Angular
Post Reply
dermaga
Posts: 3
Joined: 27 Jan 2017, 16:07

22 Feb 2018, 16:25

I am using the new <p-table> of Primeng and I would like to set the first column static and generate the following columns dynamically.

In the first column I would set buttons for different actions for each row but I have no idea how to define the first column as static one.

Code: Select all

<p-table [columns]="cols" [value]="cars">
    <ng-template pTemplate="header" let-columns>
        <tr>
            <!--
             <th>
               Action
             </th>
            -->
            <th *ngFor="let col of columns">
                {{col.header}}
            </th>
        </tr>
    </ng-template>
    <ng-template pTemplate="body" let-rowData let-columns="columns">
        <tr>
            <!--
             <td>
               <button>...
             </td>
            -->
            <td *ngFor="let col of columns">
                    {{rowData[col.field]}}
            </td>
        </tr>
    </ng-template>
</p-table>

jefhu
Posts: 29
Joined: 24 Feb 2017, 22:27

22 Feb 2018, 21:07

You can check out https://www.primefaces.org/primeng/#/table/selection

In "Column Selection", the table has an extra column hosting search button.

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 23 guests