primeng icon indicating copy to clipboard operation
primeng copied to clipboard

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

Open anugoyal12 opened this issue 9 years ago • 7 comments

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 =

anugoyal12 avatar Jan 09 '17 21:01 anugoyal12

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

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

henritoivar avatar Apr 22 '17 12:04 henritoivar

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

cagataycivici avatar Jun 19 '17 11:06 cagataycivici

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

RendyRex avatar Oct 04 '18 10:10 RendyRex

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.

Mkahnke avatar Oct 24 '18 13:10 Mkahnke

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 }

rawanujoom avatar Nov 02 '18 01:11 rawanujoom

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 avatar Feb 12 '20 16:02 daleclements

@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.

Destabilizator avatar Jul 31 '20 10:07 Destabilizator