【发布时间】:2021-02-06 03:14:18
【问题描述】:
所有关于使用 MatTableModule 进行过滤的文章都建议添加一个 MatInputModule,用户可以在其中输入搜索/过滤文本:
<mat-form-field>
<mat-label>Filter Product</mat-label>
<input matInput type="text" [(ngModel)]="filterValue"
(blur)="filterProduct(filterValue)" placeholder="Search product name">
</mat-form-field>
当用户输入搜索/过滤文本时,上面的代码sn-p会调用函数filterProduct(...)。
这就是filterProduct(...) 函数的样子:
public filterProduct = (value: string) => {
this.dataSource.filter = value;
}
这是处理过滤的常用代码 - this.dataSource.filter = value;
所以这表明过滤器应用于all 中的字段 dataSource MatTableModule 数据。
有没有办法为 MatTableModule 数据中的每个字段添加单独的过滤器?
【问题讨论】: