angularprimengprimeng-datatable

Module '"primeng/utils"' has no exported member 'FilterUtils'


After upgrading Angular to v15 I am getting this error:

Module '"primeng/utils"' has no exported member 'FilterUtils'.

Is there any alternative of filtering like this without code changes?

import { FilterUtils } from 'primeng/utils';

filterStatus(event: Switch, dt: Table): void { 
  this.showErrorOnly = event.checked;
  if (event.checked) {
    dt.value = FilterUtils.filter(this.data, ['validation.status'], 'INVALID', 'contains');
  } else {
    dt.value = this.data;
  }
  dt.reset()
}

Solution

  • FilterUtils were removed in PrimeNG 11 and the FilterService class was provided as the replacement:

    import { FilterService } from 'primeng/api';
    
    @Component({
      ...
      providers: [FilterService] // you can also provide it globally in the AppModule
    })
    class SomeComponent {
      constructor (private readonly filterService: FilterService) {}
    
      filterStatus(event: Switch, dt: Table): void { 
        this.showErrorOnly = event.checked;
        if (event.checked) {
          dt.value = this.filterService.filter(this.data, ['validation.status'], 'INVALID', 'contains');
        } else {
          dt.value = this.data;
        }
        dt.reset();
      }
    }