AngularMaterial表格filterPredicate未被调用
创始人
2024-10-28 08:01:34
0

可能是因为未正确设置filterPredicate导致,可以在设置数据源时将filterPredicate传递给MatTableDataSource对象。例如:

import { MatTableDataSource } from '@angular/material/table';

export class MyComponent implements OnInit {
  displayedColumns: string[] = [/* ... */];
  dataSource = new MatTableDataSource(/* ... */);

  ngOnInit() {
    this.dataSource.filterPredicate = (data: MyData, filter: string) =>
      data.property.toLowerCase().includes(filter.toLowerCase());
  }
  /* ... */
}

如果仍然不起作用,可能需要使用手动的过滤方法,例如:

applyFilter(event: Event) {
  const filterValue = (event.target as HTMLInputElement).value;
  this.dataSource.filter = filterValue.trim().toLowerCase();
  // Manually invoke filterPredicate
  this.dataSource.filteredData = this.dataSource.data.filter(this.dataSource.filterPredicate);
}

确保filterPredicate函数返回正确的过滤结果,并手动调用过滤方法,以确保筛选正确应用。

相关内容

热门资讯

透视安装!hhpoker怎么开... 透视安装!hhpoker怎么开透视,wepoker底牌透视脚本app,新手必备(有挂教程)1、玩家可...
透视挂!aapoker脚本怎么... 透视挂!aapoker脚本怎么用,wepoker底牌透视脚本http,玩家必备科普(有挂介绍);1、...
透视模拟器!红龙poker脚本... 透视模拟器!红龙poker脚本,wpk透视辅助,一起来探讨(有挂规律);所有人都在同一条线上,像星星...
透视神器!wepoker透视脚... 透视神器!wepoker透视脚本网页,wpk辅助器是真的吗,一秒答解(有挂黑科技);1、超多福利:超...
透视总结!hhpoker透视下... 透视总结!hhpoker透视下载链接在哪里,wpk辅助插件叫什么,查到实测辅助(有挂教学)1)辅助挂...
透视神器!wepoker辅助器... 透视神器!wepoker辅助器下载,智星菠萝辅助,实测教程(有挂详情)1、完成透视辅助安装,帮助玩家...
透视透视!aapoker透视脚... 透视透视!aapoker透视脚本下载,红龙poker作弊指令,玩家必用(有挂总结);在进入辅助挂后,...
透视辅助!hhpoker万能辅... 透视辅助!hhpoker万能辅助器,hhpoker的辅助是真的吗,可靠教程(果然真的是有挂);wpk...
透视模拟器!德普之星辅助功能如... 透视模拟器!德普之星辅助功能如何打开,红龙poker辅助,发现一款(有挂攻略);辅助器中分为三种模型...
透视教学!wepoker辅助下... 透视教学!wepoker辅助下载,wepoker有机器人吗,切实教程(从来有挂)1、不需要AI权限,...