简体   繁体   English

有没有办法在p下拉菜单上使[resetFilterOnHide] =“ true”来与primeng 5.2.7一起使用?

[英]Is there a way to get [resetFilterOnHide]=“true” on p-dropdown to work with primeng 5.2.7?

The [resetFilterOnHide]="true" on p-dropdown does not work. p下拉菜单上的[resetFilterOnHide] =“ true”不起作用。 If I type in the filter bar, click outside of the dropdown to close it, and then enter the dropdown again, the filter I entered is still there. 如果我在过滤器栏中键入内容,请在下拉列表的外部单击以将其关闭,然后再次输入该下拉列表,则我输入的过滤器仍然存在。

I am using primeng 5.2.7 in an angular 4 application. 我在angular 4应用程序中使用primeng 5.2.7。 Unfortately I cannot upgarde these to the latest versions because of which I am facing some issues with the p-dropdown component of primeng. 不幸的是,我无法将它们升级到最新版本,因此,我遇到了primeng的p-dropdown组件的一些问题。 The issue is documented and fixed in primeng 6.0.1 according to https://github.com/primefaces/primeng/issues/5915 . 根据https://github.com/primefaces/primeng/issues/5915在primng 6.0.1中记录并修复了该问题。

Is there a way to fix this in primeng 5.2.7? 是否可以在primeng 5.2.7中解决此问题?

You can try to override bindDocumentClickListener() method form primeng Dropdown and make the same change as it is in: https://github.com/primefaces/primeng/commit/bbd66dfd15275761be9aa3e757825d32f0f6f531 您可以尝试覆盖bindDocumentClickListener() Dropdown形式的bindDocumentClickListener()方法,并进行以下更改: https : //github.com/primefaces/primeng/commit/bbd66dfd15275761be9aa3e757825d32f0f6f531

This should like: 这应该像:

Dropdown.prototype.bindDocumentClickListener = function() {
    if(!this.documentClickListener) {
        this.documentClickListener = this.renderer.listen('document', 'click', () => {
            if(!this.selfClick&&!this.itemClick) {
                this.hide();
                this.unbindDocumentClickListener();
            }

            this.selfClick = false;
            this.itemClick = false;
            this.cd.markForCheck();
        });
    }
}

But you should also check if hide() method exists for primeng version which you are using in Dropdown component. 但是,您还应该检查在Dropdown组件中使用的primeng版本是否存在hide()方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM