I'm trying to sort a column that has template. My understing is that when a column uses a template, the sorting should be done by responding to the sorting event.
<p-column field="activityName" [sortable]="true" (onSort)="onNameSorting($event)">
<ng-template let-col let-activity="rowData" pTemplate="body">
//..
</ng-template>
</p-column>
However, when I put a breakpoint in the event handler, nothing is happening. Am I missing something?
onNameSorting(e){
debugger; //--> the breakpoint is not being hit
//...
}
Thanks for helping
Edit
The breakpoint is being hit, the sorting is being performed. Yet no change is being reflected in the dataTable.
onNameSorting(e, dt){
debugger; //This break point is being hit now.
if(!!e.order && e.order > 0){
this.filteredItems = this.filteredItems
.sort((a, b) => (a.activityName < b.activityName) ? -1 : 1);
}else{
this.filteredItems = this.filteredItems
.sort((a, b) => (a.activityName > b.activityName) ? -1 : 1);
}
}