Angular PrimeNg: Not able to Sort columns

Viewed 28

I would like to sort specific columns of a table using Angular PrimeNG component. I added the following code based on the documentation but isn't working as expected. https://www.primefaces.org/primeng/table/sort

    <p-table [value]="tablename" [paginator]="true" [columns]="cols" [rows]="10">
<ng-template pTemplate="header" let-columns>
    <tr>
        <th>Heading1</th>
        <th pSortableColumn="name">Heading2<p-sortIcon field="name"></p-sortIcon></th>
        <th pSortableColumn="duedate">Heading3<p-sortIcon field="duedate"></p-sortIcon></th>
        <th pSortableColumn="amount">Heading4 <p-sortIcon field="amount"></p-sortIcon></th>
        <th pSortableColumn="username">Heading5<p-sortIcon field="username"></p-sortIcon></th>
        <th>Heading6</th>
    </tr>
</ng-template>

Out of these 6 headers, I am performing a sort on 4 columns, some of them work as expected but some don't. I am not sure what I am missing here. Is it because of pagination? Any help is greatly appreciated. Thank you in advance.

0 Answers
Related