i have data like so with nested json
users = [
{ name: "ABC",
age: 11,
activity : { date: 11-Aug-2020,
title: "some activity",
loc: "some loc" }
phone: "1111"
}
col definition is like so
this.colHeadingLists = [
{ colName: 'Name', fieldName: 'name', subFieldName: ''},
{ colName: 'Activity Date', fieldName: 'activity', subFieldName: 'date'},
{ colName: 'Phone', fieldName: 'phone', subFieldName: '', sortable: true }
]
with this i am able to display the table data correctly but sorting on the "Activity Date" column is not working correctly - basically it is not taking the 'date' subfield into consideration.
This is how the columns are defined in the template.
<th *ngFor="let col of colHeadingLists" id="{{col.fieldName}}"
[pSortableColumn]="col.fieldName">
<span class="fieldName"></span>{{col.colName}}
<p-sortIcon [field]="col.fieldName"></p-sortIcon>
</th>
How to tell the p-table to use the subfield name for certain columns.
thanks for the help