Multiselect filter not working for an array

UI Components for React
Post Reply
ssaha
Posts: 7
Joined: 04 Nov 2022, 10:06

04 Nov 2022, 10:17

I am trying to enable the filter option for multiselect, for the below array

incidentStatuses = ['NEW', 'ACKNOWLEDGED', 'ONHOLD', 'ESCALATED', 'RESOLVED'];

<MultiSelect value={options.value} options={this.incidentStatuses}
onChange={(e) => options.filterCallback(e.value, options.index)}
placeholder="Status" className="multiselect-custom" filter filterMatchMode={FilterOperator.CONTAINS}
/>;

This is showing the filter search in my multiselect dropdown, but when I search for the data present in the array, it's not showing anything.
Please assist on how can I achieve this ???

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

04 Nov 2022, 14:42

for arrays and lists you want `filterMatchMode={FilterMatchMode.IN}`

Code: Select all

filterMatchMode={FilterMatchMode.IN}
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

ssaha
Posts: 7
Joined: 04 Nov 2022, 10:06

05 Nov 2022, 04:57

I tired below IN match mode as well, but no luck


<MultiSelect value={options.value} options={this.incidentStatuses}
itemTemplate={this.statusItemTemplate}
onChange={(e) => options.filterCallback(e.value, options.index)}
filter filterMatchMode={FilterMatchMode.IN}
placeholder="Status" className="multiselect-custom"
/>

Looks like when I use in below way it works, but since I am using this in a datatable to filter column, the below object, does not filter my datatable, because the response I am getting from API is directly the status.

incidentStatuses = [name : 'NEW',name: 'ACKNOWLEDGED', name: 'ONHOLD', name: 'ESCALATED', name: 'RESOLVED'];

<MultiSelect value={options.value} options={this.incidentStatuses}
itemTemplate={this.statusItemTemplate}
onChange={(e) => options.filterCallback(e.value, options.index)}
filter filterMatchMode={FilterMatchMode.IN} optionLabel='name'
placeholder="Status" className="multiselect-custom"
/>

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

05 Nov 2022, 15:24

PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests