Primeng: Hello, Is there a way to get global filtered row count of a p datatable in primeng? Please help.

Created on 9 Jan 2017  路  7Comments  路  Source: primefaces/primeng

I'm submitting a ... (check one with "x")

[ ] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)
Please fork the plunkr below and create a case demonstrating your bug report. Issues without a plunkr have much less possibility to be reviewed.

http://plnkr.co/edit/NtWWnN

Current behavior

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • Angular version: 2.0.X

  • PrimeNG version: 2.0.X

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

  • Language: [all | TypeScript X.X | ES6/7 | ES5]

  • Node (for AoT issues): node --version =

Most helpful comment

Just add a reference to the datatable component and access the totalRecords attribute.

<p-dataTable #table></p-dataTable>
{{ table.totalRecords }}

All 7 comments

Just add a reference to the datatable component and access the totalRecords attribute.

<p-dataTable #table></p-dataTable>
{{ table.totalRecords }}

onFilter also gives filteredData which you can get the length from.

onFilter also gives filteredData which you can get the length from.

How does one implement this one,i want to return number of rows after filter

onFilter also gives filteredData which you can get the length from.

How does one implement this one,i want to return number of rows after filter

hey @RendyRex did you find anything to solve your problem. im facing the same right now.

now it's p-table ..to get the count of the filtered values (Displayed Rows) you can do this :
<p-table #dt .... (onFilter)="onFilter($event, dt)">
onFilter(event, dt) { this.filteredValuesLength = event.filteredValue.length; // count of displayed rows }

for anyone else coming here to find a simple solution with pTable (TurboTable), you can do it directly in the template with {{ dt.filteredValue.length }}.

It doesn't seem to be documented, but filteredValue is a member of the table component

@daleclements you are lifesaver!
Expanded a bit - the dt.filteredValue is not populated until some filtering actually happens. For inspiration
Showing {{dt.filteredValue?dt.filteredValue.length:dt.totalRecords}} of {{dt.totalRecords}} entries.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pchristou picture pchristou  路  3Comments

garethlewis picture garethlewis  路  3Comments

just-paja picture just-paja  路  3Comments

jisqaqov picture jisqaqov  路  3Comments

miresk picture miresk  路  3Comments