javascript - 使用内置过滤器时,Angular 2 ag-grid 的“清除过滤器”按钮会清除文本框而不刷新列

标签 javascript angular angular2-directives ag-grid ag-grid-ng2

启用 ag-grid 的默认过滤器时,清除过滤器按钮只会清除文本框,不会刷新列,即使“clearButton”和“applyButton”参数设置为 true。单击“清除筛选器”按钮后,文本将从文本框中清除,我必须实际单击“应用筛选器”按钮以删除筛选器并刷新列。

下面是我的代码:

 result.filter = "date";
 result.filterParams = {
     applyButton: true,
     clearButton: true
 };

有没有一种方法可以使“清除过滤器”按钮在清除文本框的同时实际刷新列?或者是否有任何事件可用于我们可以订阅的清除按钮单击? (在文档中没有提到清除按钮点击的任何事件)

帮助将不胜感激

最佳答案

监听器可以附加到某些特定过滤器的清除按钮的点击事件,在监听器内部我们可以调用 this.gridOptions.api.onFilterChanged() 来触发更改。

let filterInstance = this.gridOptions.api.getFilterInstance("name_col");

filterInstance.eClearButton.addEventListener("click", () => {
    this.gridOptions.api.onFilterChanged();
 });

关于javascript - 使用内置过滤器时,Angular 2 ag-grid 的“清除过滤器”按钮会清除文本框而不刷新列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46539008/

相关文章:

angular - 为什么我的 http.put 请求不起作用?均值堆栈

typescript - Angular2 http 缺少 .map 函数

validation - Angular 2 中的条件必需验证器指令

angular - 将 Angular 2 node_modules 文件编译为一个文件

typescript - Angular2通过属性将函数传递给指令

javascript - 如何重新组合html5 Animate-CC Publishes(因为之前文件太大)?

javascript - 无法在 Javascript 中匹配此正则表达式

javascript - 无法从委托(delegate)函数访问类属性

javascript - CSS 类的命名空间/前缀,在 Javascript 和 (S)CSS 之间共享

javascript - @Input() 问题