Reputation: 755
I have the following primeng datatable configuration:
private cars : any =
{
"data": [
{ "time": "9:30AM-10:30AM",
"Monday": {"Subject": "Physics"},
"Tuesday": 2012,
"Wednesday": "Orange",
"Thursday": "dsad231ff",
"Friday": "dsad231ff"
},
{ "time": "10:30AM-11:00AM",
"Monday": {"Subject": "Maths"},
"Tuesday": 213213,
"Wednesday": "efrwr",
"Thursday": "dsad231ff",
"Friday": "aaaaa"
},
]
}
cols: any = [
{field: 'time', header: ''},
{field: 'Monday', header: 'Monday'},
{field: 'Tuesday', header: 'Tuesday'},
{field: 'Wednesday', header: 'Wednesday'},
{field: 'Thursday', header: 'Thursday'},
{field: 'Friday', header: 'Friday'}
];
and html:
<p-dataTable [value]="cars">
<p-column *ngFor="let col of cols" [field]="col.field" [header]="col.header"></p-column>
</p-dataTable>
As u can see in data one of the value is an object "Monday": {"Subject": "Physics"},
In the table cell how can I display the value of the object with key Subject
? Currently i see an Object in my cell. Thanks in advance guys
Upvotes: 0
Views: 1759
Reputation: 1047
@blackdaemon,
Update your cols configuration as below: {field: 'Monday.Subject', header: 'Monday'}
PrimeNg refers to fields as objects.
Please try and update.
Upvotes: 1