我在Angular 6应用程序中使用的是Enterprise Ag-Grid版本。我有一个Set Filter。我在过滤器中添加了“应用”按钮:
apply:设置为true以在过滤器中添加“应用”按钮, 不会随着选择的变化而自动过滤。
问题是按下按钮后如何隐藏迷你滤镜菜单?我没有在官方网站上找到有关此可能性的任何文档。但是我在内部库src文件中找到一条注释,并在IComponent.ts
中进行了指定:
/* A hook to perform any necessary operation just after the gui for this component has been renderer
in the screen.
If the filter popup is closed and reopened, this method is called each time the filter is shown.
This is useful for any
logic that requires attachment before executing, such as putting focus on a particular DOM
element. The params has one callback method 'hidePopup', which you can call at any later
point to hide the popup - good if you have an 'Apply' button and you want to hide the popup
after it is pressed. */
afterGuiAttached?(params?: IAfterGuiAttachedParams): void;
目前我还不了解如何设置afterGuiAttached
函数来实现上述目标。
有人可以帮我吗?
提前致谢!
答案 0 :(得分:1)
您已经检查过afterGuiAttached
是Filter Component
的一部分
因此可以在自定义过滤器like here中访问此函数。
因此,您要做的就是在内部定义afterGuiAttached
:
export class PartialMatchFilter implements IFilterAngularComp {
afterGuiAttached(params){
params.hidePopup() <- executing will close the filter
}
}
afterGuiAttached
-如所述在init
上执行(但是Apply按钮也将是自定义的,您应该自行处理)。您可以将hidePopup
函数绑定到自定义过滤器参数,并在需要时使用它。
export class PartialMatchFilter implements IFilterAngularComp {
private hideFilter:Function;
afterGuiAttached(params){
this.hideFilter = params.hidePopup;
}
}
执行this.hideFilter()
将关闭您的过滤器;
我根据引用的演示制作了dummy sample