Implementing NGX Datatable filtering on all columns

后端 未结 8 751
不知归路
不知归路 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:27

    import { DatatableComponent } from '@swimlane/ngx-datatable';
    ViewChild(DatatableComponent) table: DatatableComponent;
    
       updateFilter(event) {
        const val = event.target.value.toLowerCase();
        var returnData: any;
        // filter our data
        const temp = this.temp.filter(function (d) {
          if (d.yourFirstColumnName.toLowerCase().indexOf(val) !== -1 || !val) {
            returnData = d.user_name.toLowerCase().indexOf(val) !== -1 || !val;
          } else if (d.yourSecondColumnName.toLowerCase().indexOf(val) !== -1 || !val) {
            returnData = d.notes_title.toLowerCase().indexOf(val) !== -1 || !val;
    
          }
          return returnData;
        });
    
     
    

提交回复
热议问题