You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use (sortFunction)="customSort($event)" for custom sorting.
callback function returns following information in event object:
//event.data = Data to sort
//event.mode = 'single' or 'multiple' sort mode
//event.field = Sort field in single sort
//event.order = Sort order in single sort
//event.multiSortMeta = SortMeta array in multiple sort
Example:
<p-table` [columns]="cols" [value]="cars" (sortFunction)="customSort($event)" [customSort]="true">
<ng-template pTemplate="header" let-columns>
<tr>
<th *ngFor="let col of columns" [pSortableColumn]="col.field">
{{col.header}}
<p-sortIcon [field]="col.field"></p-sortIcon>
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData let-columns="columns">
<tr>
<td *ngFor="let col of columns">
{{rowData[col.field]}}
</td>
</tr>
</ng-template>
</p-table>
Define a callback called sortFunction, that receives the sort information and implements sorting instead of the built-in sorting.
The text was updated successfully, but these errors were encountered: