BlackICE
BlackICE

Reputation: 8926

Clear PrimeNg multiselect filter value programatically

During a click event for performing some business process I need to clear the selected values (which I have done) and the filter value for PrimeNG multiselect. I don't see a way to programmatically access the filter value of the multiselect, is this possible and if so how? I would rather not use the resetFilterOnHide property.

Upvotes: 3

Views: 2037

Answers (1)

Pankaj Bhandarkar
Pankaj Bhandarkar

Reputation: 498

There is an option to clear the filter input value using onFilterShow / onFilterHide event, there is option called _filterValue of the element to set value as following:

HTML:

<p-multiSelect #element [options]=".data" [(ngModel)]="selectedItems"
        optionLabel="label" optionValue="label"
        [filter]="true" (onPanelShow)="onPanelShow(element)">

TS:

  onPanelShow(element: any) {
    element._filterValue = ''
  }

Note: PrimeNg V12.0 LTS

This may help you.

Upvotes: 2

Related Questions