Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search filter for all pages not working in Angular 8. #368

Open
shivangi53 opened this issue Sep 21, 2020 · 11 comments
Open

Search filter for all pages not working in Angular 8. #368

shivangi53 opened this issue Sep 21, 2020 · 11 comments

Comments

@shivangi53
Copy link

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 #178 (comment)

@shivangi53 shivangi53 changed the title 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? Search filter for all pages not working in Angular 8. Sep 21, 2020
@michaelbromley
Copy link
Owner

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:


@shivangi53
Copy link
Author

shivangi53 commented Sep 21, 2020

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

This comment has been minimized.

@michaelbromley
Copy link
Owner

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.

@AyushGupta838
Copy link

What have you done next?

@Ahsanbaloch
Copy link

Anyone find the solution?

@shivangi53
Copy link
Author

shivangi53 commented Mar 16, 2021

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

@Ahsanbaloch
Copy link

Thank you @shivangi53

@KGP8
Copy link

KGP8 commented Jul 26, 2021

Anyone find the solution about ng2SearchFilter ?

@salehudeen
Copy link

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.

@PgStudy143
Copy link

Use totalItems: datasource.length in pagination

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants