Implementing NGX Datatable filtering on all columns

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

    While storing the data in rows list at that time also initilize perttemp list, so that we can fetch after filter

    updateFilter(event) {
    
        const val = event.target.value.toLowerCase();
        if(val) {
            this.temp = this.rows;
            // filter our data
            const temp = this.temp.filter(function (d) {
              return ( d.name.toLowerCase().indexOf(val) !== -1 || d.email.toLowerCase().indexOf(val) !== -1 || !val);
            });
            this.rows = temp;
        }
        else
        {
            this.rows = this.perttemp;
        }
    }
    

提交回复
热议问题