angularng2-smart-table

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


Solution

  • 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;
      }))
     }