Looking for a way to default empty cells in my primeng datatable to '-'.
Consider the following data:
[
{
'column': null
},
{
'column': {
'name': 'A'
}
},
{
'column': {
'name': 'B'
}
},
{
'column': null
}
]
The configuration of my primeng column is as follows:
{
field: 'column.name',
header: 'Name',
sortable: true
}
However, the current setup does not work when "column" may or may not have the property "name". It sets all fields in this column to '-', regardless of the presence of "name".
<p-column [field]="col.field" [header]="col.header" [sortable]="col.sortable">
<template let-col let-data="rowData" pTemplate="body">
{{data[col.field] ? data[col.field] : "-"}}
</template>
</p-column>
If you have any ideas on how to solve this issue, please share!