简体   繁体   English

如何添加清除按钮以过滤多选primeng angular

[英]How to add clear button to filter in multiselect primeng angular

I am trying to make multiselect with a filter.我正在尝试使用过滤器进行多选。 I need to clear the filter after filtering (not the selecting).我需要在过滤后清除过滤器(不是选择)。 I used prime ng multiselect and it does not have property to address this requirement.我使用了prime ng multiselect,它没有解决这个要求的属性。

below is my code.下面是我的代码。

<p-multiSelect 
  [options]="subjectTitles" 
  [showToggleAll]="false" 
  [(ngModel)]="selectedTitle 
  [ngModelOptions]="{ standalone: true }" 
  optionLabel="title" 
  defaultLabel="Select title"  
  [filter]="true 
  [itemSize]="30" 
  filterPlaceHolder="Search title" 
  #select="ngModel" 
  required 
  (onPanelHide)="panelClosed = true" 
  class="multiselect-custom-virtual-scroll" >
</p-multiSelect>`

Can I know if anyone has a solution for this?我可以知道是否有人对此有解决方案吗?

onPanelShow event of p-multiselect, set the type of multiselect filter input as 'search'. p-multiselect 的 onPanelShow 事件,设置多选过滤器输入的类型为 'search'。

(onPanelShow)="onMsPanelShow()"

onMsPanelShow()
{
    if(document.getElementsByClassName(
    "p-multiselect-filter p-inputtext p-component"
    )){
        document.getElementsByClassName(
        "p-multiselect-filter p-inputtext p-component"
        ).item(0).setAttribute("type","search");
    }
}

PS It may not work with IE browser. PS 它可能不适用于 IE 浏览器。

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

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