ngx-pagination icon indicating copy to clipboard operation
ngx-pagination copied to clipboard

Search filter for all pages not working in Angular 8.

Open shivangi53 opened this issue 5 years ago • 11 comments

I am having the same issue. I have used ng2 search filter and ngx pagination in my HTML file of angular project. I am able to search within pages but not all pages. I have even put the filter first and then paginate but it's still not working. Can you please help me out of this?

Originally posted by @shivangi53 in https://github.com/michaelbromley/ngx-pagination/issues/178#issuecomment-696118195

shivangi53 avatar Sep 21 '20 13:09 shivangi53

Hi. Please fill out the issue template:

Angular version:

ngx-pagination version:

Description of issue:

Steps to reproduce:

Expected result:

Actual result:

Demo: (if possible, edit this StackBlitz demo and paste the link to your fork)

Any relevant code:


michaelbromley avatar Sep 21 '20 15:09 michaelbromley

Hi. Please fill out the issue template:

Angular version: 9.0.7 Node : 12.7.0

ngx-pagination version:5.0.0

Description of issue: I have used ng2 search filter and ngx pagination but still I'm able to search within the pages and not in all pages. I am able to search the data of first page in first page only. The data of second page in second page only. But I'm not able to search the data of one page into another. If I do it the page comes empty.

Steps to reproduce:

HTML Code:

<tr *ngFor ="let game of games| filter :term| paginate: {itemsPerPage:5, currentPage:p}; let i = index" >
<td>{{game.name}}</td>
<td>{{game.genre}}</td>
</tr>
</tbody>
</table>
<pagination-controls directionLinks="true" (pageChange)="p = $event"></pagination-controls>

Expected result: I want the search to happen in all pages. Like if I search the data of first page from the third page then also the output should come. Instead of coming empty.

Actual result: The data of first page gets searched in the first only. The data of second page gets searched in the second only. And respectively for every page.

Demo: (if possible, edit this StackBlitz demo and paste the link to your fork)

Any relevant code: HTML Code:

<tr *ngFor ="let game of games| filter :term| paginate: {itemsPerPage:5, currentPage:p}; let i = index" >
<td>{{game.name}}</td>
<td>{{game.genre}}</td>
</tr>
</tbody>
</table>
<pagination-controls directionLinks="true" (pageChange)="p = $event"></pagination-controls>

shivangi53 avatar Sep 21 '20 16:09 shivangi53

Screenshot_20200922-022625

shivangi53 avatar Sep 21 '20 20:09 shivangi53

Thanks for the info. By the way - if you want to show code, surround it in 3 back-ticks:

```
<div>....</div>
```

Since I don't know about the ng2 search filter library, I cannot know what exactly it does or how it interacts with this library to cause the issue. If you can reproduce the behaviour using this Stackblitz demo as the basis, then I can investigate further.

michaelbromley avatar Sep 22 '20 06:09 michaelbromley

What have you done next?

AyushGupta838 avatar Mar 04 '21 06:03 AyushGupta838

Anyone find the solution?

Ahsanbaloch avatar Mar 16 '21 06:03 Ahsanbaloch

The ng2 search filter didn't work fine for me. So instead I used filter keyword on the array to fetch the search item.

shivangi53 avatar Mar 16 '21 06:03 shivangi53

Thank you @shivangi53

Ahsanbaloch avatar Mar 16 '21 06:03 Ahsanbaloch

Anyone find the solution about ng2SearchFilter ?

KGP8 avatar Jul 26 '21 05:07 KGP8

I'm not sure how this will help, but I managed to solve the issue by placing my filter pipe before my pagination pipe like the below example: -

| filter :searchValue | paginate: { itemsPerPage:8, currentPage:page, totalItems:totalLength }

hope this helps its been buggin me for a while to be honest.

salehudeen avatar Sep 15 '22 16:09 salehudeen

Use totalItems: datasource.length in pagination

PgStudy143 avatar Sep 20 '22 08:09 PgStudy143