PrimeNG sort using array object

UI Components for Angular
Post Reply
akanzari90
Posts: 1
Joined: 02 Apr 2021, 12:32

02 Apr 2021, 12:34

I wanted to know if it was possible to use an array of objects for sorting something into a table ?

I'm using Angular 11 and PrimeNG 11.0.0-rc.1

Code: Select all

this.cols = [        
    { field: 'day', header: 'Jour' },
    { field: 'class', header: 'Classe', type: "object", subField: 'classId'}
];

<ng-template pTemplate="header" let-columns>
    <tr>
       <th *ngFor="let col of columns" [pSortableColumn]="col.hasOwnProperty('subField') ? col.subField :  col.field">
            {{col.header}} 
            <p-sortIcon [field]="col.hasOwnProperty('subField') ? col.subField :  col.field"></p-sortIcon>
       </th>
    </tr>
    <tr>
       <th *ngFor="let col of columns">
           <p-columnFilter type="text" [field]="col.hasOwnProperty('subField') ? col.subField :  col.field" display="menu"></p-columnFilter>
       </th>
    </tr>
</ng-template>
I tried with the above code, but it not working

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 23 guests