更新时间:2023-11-20 12:30:40
you should use filterPredicate property of MatTableDataSource
you should use filterPredicate property of MatTableDataSource
初始化this.dataSource后,定义一个自定义filterPredicate函数如下;
after you initialize this.dataSource, define a custom filterPredicate function as follows;
this.dataSource = new MatTableDataSource(results);
this.dataSource.sort = this.sort;
this.dataSource.filterPredicate = function(data: any, filterValue: string) {
return data.specificColumn /** replace this with the column name you want to filter */
.trim()
.toLocaleLowerCase().indexOf(filterValue.trim().toLocaleLowerCase()) >= 0;
};