首页 > 解决方案 > 在按钮点击条件下过滤 mat-table

问题描述

我有一个垫表,我想过滤它以显示表中权重大于 10 的行。关于如何完成此操作的任何建议?

请在此处查看我的堆栈闪电战:

https://stackblitz.com/edit/angular-4ttand?file=src/app/table-basic-flex-example.ts

标签: angularangular-material

解决方案


我已经为您的用例添加了逻辑。请检查一下。

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);
}

推荐阅读