如何从 table 中删除行? - "ag-grid"

How can I remove rows from a table? - "ag-grid"

我在 Angular 项目中使用 ag-grid 库。我试图通过使用 doesExternalFilterPass 来阻止某些节点显示在 table 中。

doesExternalFilterPass 方法针对 table 中的每个节点运行,如果方法 returns false 如果我从他们的文档中正确理解它,则不应显示它:

doesExternalFilterPass is called once for each row node in the grid. If you return false, the node will be excluded from the final set.

下面是我的代码:

doesExternalFilterPass(node: any) {
    for(let i = 0; i < this.columnDefs.length; i++) {
        var temp = this.columnDefs[i].headerName;

        if(node.data[temp] === 'Declined') {
            console.log('found);
            return false;
        }
    }
}

代码运行成功,控制台打印“found”。上面的代码从列的 Filter List 中删除了值 'Declined',但是具有值 'Declined' 的行仍然显示在 table.

如何完全删除具有 'Declined' 值的行?

您的指导将不胜感激。

在我看来,您甚至希望在将数据显示在网格中之前从数据中过滤掉这些对象,所以如果我没有误解您的问题,那么简单的 filter 就可以了:

this.myData = this.myData.filter(obj => obj.someProperty !== "Declined");

// then create the grid

显然将变量和 属性 名称更改为您的名称。