How to add "No Record Found" in PrimeNG Datatable When data is not there?
According to the official documentation this is now available as a template.
When there is no data, DataTable displays a message text defined using the emptyMessage property where as custom content can be provided using emptymessage template.
<p-dataTable [value]="cars" [responsive]="true">
<p-column field="vin" header="Vin"></p-column>
<p-column field="year" header="Year"></p-column>
<p-column field="brand" header="Brand"></p-column>
<p-column field="color" header="Color"></p-column>
<ng-template pTemplate="emptymessage">
Custom content goes here
</ng-template>
</p-dataTable>
You just put after ng-template pTemplate="body"
tag with this code:
<ng-template pTemplate="emptymessage" let-columns>
<tr>
<td [attr.colspan]="columns.length">
No records found
</td>
</tr>
</ng-template>