Filtering Data Table in PrimeNG


How can I get the number of rows after filtering using PrimeNG’s default filters in data table.

[totalRecords]="totalRecords" always shows the records count which is fetched initially.

Even though after filtering, totalRecords value remains same and does not change after filtering.

initially totalRecords is 50 and after filtering, no.of records it shows in data table is 15. But I cannot get the value 15, instead getting 50.

Is there any way ?


Supposing you have a reference to your datatable component, just ask totalRecords property on it :

<p-dataTable [value]="cars" [rows]="10" [paginator]="true" [globalFilter]="gb" #dt>

{{ dt.totalRecords }} records


Answered By – Antikhippe

Answer Checked By – David Goodson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.