Ag grid 自定义过滤器:我可以为过滤器自定义按钮吗?
我正在尝试启用自己的自定义筛选器。Ag grid 自定义过滤器:我可以为过滤器自定义按钮吗?,ag-grid,angular,javascript,ag-grid-ng2,Ag Grid,Angular,Javascript,Ag Grid Ng2,我正在尝试启用自己的自定义筛选器。 除了Apply按钮之外,我还想为过滤器设置其他按钮。i、 如果我能在某种UI中解释这一点 |--自定义过滤器-----------------. |过滤文本:uuuuuuuuuuuuuuuuuu124; |应用|清除|全部清除| |_______________________| 通过使用ag grid的默认过滤器组件,我知道如果我在ColDef中提供filterParams,我可以有两个按钮 filterParams: { applyButton:
除了
Apply
按钮之外,我还想为过滤器设置其他按钮。i、 如果我能在某种UI中解释这一点
|--自定义过滤器-----------------.|过滤文本:uuuuuuuuuuuuuuuuuu124;
|
应用
|清除
|全部清除
||_______________________| 通过使用
ag grid
的默认过滤器组件,我知道如果我在ColDef
中提供filterParams
,我可以有两个按钮
filterParams: {
applyButton: true,
clearButton: true
}
但是另一个自定义(
全部清除
)按钮呢?有什么方法可以实现它吗?经过几个小时的搜索和试错后实现了它
请看下面给出的示例:
请查看PartialMatchFilterComponent
及其代码
在对模板和组件进行一些代码更新之后,我们就可以实现它了
更新模板:
<button (click)="apply()">Apply</button>
<button (click)="clear()">Clear</button>
<!-- any other buttons you want to keep -->
:先生,我的筛选器更改回调未定义,您能告诉我为什么未定义吗?
apply(): void {
this.params.filterChangedCallback();
}
clear(): void {
this.text = '';
this.params.filterChangedCallback();
}
onChange(newValue): void {
if (this.text !== newValue) {
this.text = newValue;
// this.params.filterChangedCallback(); - remove
}
}