1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

PrimeNG Table and reusable table template fragments

Discussão em 'Angular' iniciado por user3626048, Setembro 25, 2024.

  1. user3626048

    user3626048 Guest

    I'm using PrimeNG 12.0.1 and its Table to display data in my Angular application.

    I have separate @Component which contains <p-table> in html template. Inside <p-table> there's ng-templates to display table parts like pTemplate="colgroup", pTemplate="header", pTemplate="body" etc.

    I would like to move these parts to separate files to be able to reuse them in new Component which will also have <p-table>. How to achieve that to move these elements to other file (Component?) and have working table?

    Below some current code fragments:

    <p-table #table [value]="userDataSource.data$ | async" [columns]="displayedColumns" ........>

    <ng-template pTemplate="colgroup" let-columns>
    <colgroup>
    <col *ngFor="let col of columns" [ngStyle]=".........">
    </colgroup>
    </ng-template>

    <ng-template pTemplate="header" let-columns>
    <tr>
    <ng-container *ngFor="let col of columns">
    .........
    </ng-container>
    </tr>
    </ng-template>

    <ng-template pTemplate="body" let-row let-columns="columns" let-expanded="expanded">
    <tr (click)="rowClicked(row)" class="...........">
    <ng-container *ngFor="let column of columns">
    ................
    </ng-container>
    </tr>
    </ng-template>

    </p-table>

    Continue reading...

Compartilhe esta Página