Hi have a Data table with 4 cols- Name, Age, Marks, School. Now I want to apply filter for each of the columns. The filter works fine individually. But I am not able to combine the results of filter - example I am not able to filter out the Name which has marks > 90 and from 'abc' School.
I tried something like this, but it did not work.
applyFilter(filterValue: string) {
console.log("Filter is applied upon:",this.dataSource)
let initialDataSource = this.dataSource;
this.dataSource.filter = filterValue.trim().toLowerCase();
this.filteredDataSource = this.dataSource.filteredData
this.filterVal = this.dataSource.filter;
if(this.filterVal.length != 0){
this.dataSource = new MatTableDataSource(this.filteredDataSource);
this.dataSource.filter = filterValue.trim().toLowerCase();
}else{
this.dataSource = initialDataSource;
this.dataSource.filter = filterValue.trim().toLowerCase();
this.filteredDataSource = this.dataSource.filteredData
}
}
The above function does the filtering, but when I clear out the filter value, the table data does not change. Also it does not change when I delete a character.