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

NGX pagination search filter is not working after page change in angular #396

Open
bilusau opened this issue Jul 27, 2022 · 1 comment
Open

Comments

@bilusau
Copy link

bilusau commented Jul 27, 2022

This is search filter directives

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'filter'
})
export class FilterPipe implements PipeTransform {
  transform(items: any[], searchText: string): any[] {
    if (!items) return [];
    if (!searchText) return items;
  
    return items.filter(item => {
      return Object.keys(item).some(key => {
        return String(item[key]).toLowerCase().includes(searchText.toLowerCase());
      });
    });
   }
}

Below is the HTML code with array table

<input type="search" class="col-sm-3.1 m_left16 " id="searchAll" [(ngModel)]="searchAllDataBenchmark"
                                        placeholder="Search by keywords" autocomplete="off">

<tr *ngFor="let i of userArray2 | filter: searchAllDataBenchmark | paginate: { itemsPerPage: 8, currentPage: p } ">


<pagination-controls (pageChange)="p = $event"></pagination-controls>

It's working properly when stay in 1st page in the pagination search filter is working. But when click the send page and search any table data it's not working and data table is not filtering. Data table array is showing blank.

Angular Version is: 13.1.0
ngx-pagination: 5.1.1

@kakarotx10
Copy link

have found any solution????

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

2 participants