Implementing NGX Datatable filtering on all columns

后端 未结 8 760
不知归路
不知归路 2021-02-06 04:21

I\'ve been trying to get this working with no luck. I\'ve been referencing these resources for help: http://swimlane.github.io/ngx-datatable/#filter
https://github.com/swiml

8条回答
  •  终归单人心
    2021-02-06 04:42

    here is an example of your code with multiple columns filtering:

    updateFilter(filter: string): void {
    
      const val = filter.trim().toLowerCase();
    
      this.filteredList = this.items.slice().filter((item: any) => {
        let searchStr = '';
        for (let i = 0; i < this.gridProperties.FilteredColumns.length; i++) {
          searchStr += (item[this.gridProperties.FilteredColumns[i]]).toString().toLowerCase();
        }
        return searchStr.indexOf(val) !== -1 || !val;
      });
    }
    

    If I did not made any errors, it should work correctly.

提交回复
热议问题