angular - 在按钮点击条件下过滤 mat-table
问题描述
我有一个垫表,我想过滤它以显示表中权重大于 10 的行。关于如何完成此操作的任何建议?
请在此处查看我的堆栈闪电战:
https://stackblitz.com/edit/angular-4ttand?file=src/app/table-basic-flex-example.ts
解决方案
我已经为您的用例添加了逻辑。请检查一下。
filterTable() {
// logic here to filter table showing only rows that have a weight > 10
this.dataSource = this.dataSource.filter((item) => {
console.log(Math.floor(item.weight));
return Math.floor(item.weight) > 10});
console.log('***********', this.dataSource);
}
推荐阅读
- math - 这个方程是什么意思 N(1 <= N <= 100)
- spring - 如何从多个 RepositoryItemReaders 读取并写入一个 RepositoryItemWriter
- c# - ExportRenderer 上的`System.Reflection.TargetInvocationExceptionExportRenderer`
- python - 从 Python 创建 PNG 文件并确保某些单元格是透明的
- javascript - 光滑的轮播:滑动可变数量的元素
- c# - 1 Uncaught (in promise) SyntaxError: Unexpected token 。在 JSON 中的位置 4
- c++ - 容器的模板化元素比较函数
- azure - Azure 上的 nginx 入口设置(不使用 helm)故障排除
- python - Py Selenium find elements inside element not working
- react-redux - Redux-Form 多行 Google Material UI TextField 在显示后不会自动调整大小