【问题标题】:How to get a notification of column name/filter type when a filter is applied to a ag grid column将过滤器应用于 ag 网格列时如何获取列名/过滤器类型的通知
【发布时间】:2023-03-06 18:08:01
【问题描述】:

我试图在我更改过滤器/在 ag 网格上应用过滤器时收到通知。下面是我尝试过的代码。

在我的 component.html 中我添加了(filterChanged) = 'filterChanged($event)' .

在component.ts我的代码如下,

filterChanged(params){
this.params =params; 
this.gridApi = params.api; // To access the grids API
this.gridColumnApi = params.columnApi;
var filterInstance = this.gridApi.filterManager.allFilters;
alert("Filter applied"+filterInstance);
}

但是在警报中,我得到的是对象对象,不知道为什么会这样。谁能帮忙解决这个问题。

我参考了以下链接 -

[ag grid : js : How to find which filter is applied

【问题讨论】:

    标签: angular filter ag-grid


    【解决方案1】:

    filterInstance 是一个对象,当你使用时

    alert("Filter applied"+filterInstance);
    

    Javascript 使用filterInstance.toString() 将其隐式转换为字符串,以便在浏览器中显示。任何对象toString() 都会给你[object Object],这不是很有用。如果要查看 JSON 格式的数据,可以使用:

    alert("Filter applied" + JSON.stringify(filterInstance));
    

    【讨论】:

    • 是的,现在我可以按预期获取 json,但我只得到第一个过滤的字符串。如果选择一个过滤器,它不会给出。还有其他方法可以应用所有过滤器吗?
    • @AkshayKrishna 你用的是什么版本的ag-grid
    • ag网格版本为:v18.1.2
    猜你喜欢
    • 2020-12-01
    • 2018-09-06
    • 2020-06-12
    • 1970-01-01
    • 2017-01-14
    • 1970-01-01
    • 2012-06-04
    • 1970-01-01
    • 2020-07-18
    相关资源
    最近更新 更多