且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在特定列的角材料数据表中进行过滤

更新时间: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;
};