Solomon Sahayaraj
Solomon Sahayaraj

Reputation: 23

Is it possible to use Standalone filter along with column filters?

I understand we can use a Standalone filter without individual column filters (https://akveo.github.io/ng2-smart-table/#/examples/using-filters) But is it possible to use both?

I tried to implement it but could not. See https://stackblitz.com/edit/angular-2cwakj?file=src%2Fapp%2Ffilter-poc%2Ffilter-poc.component.ts

Upvotes: 2

Views: 425

Answers (1)

sacgro
sacgro

Reputation: 469

Change your onSearch function with following function.

  onSearch(query: string = '') {
   this.source = new LocalDataSource(this.data.filter((obj)=>{
   if(obj.id.toString().indexOf(query)>-1 || obj.name.indexOf(query)>-1 || 
    obj.username.indexOf(query)>-1 ||obj.email.indexOf(query)>-1 ) return true;
   else false;
  }))
 }

Upvotes: 2

Related Questions