Page 1 of 1

Multiselect filter not working for an array

Posted: 04 Nov 2022, 10:17
by ssaha
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 ???

Re: Multiselect filter not working for an array

Posted: 04 Nov 2022, 14:42
by Melloware
for arrays and lists you want `filterMatchMode={FilterMatchMode.IN}`

Code: Select all

filterMatchMode={FilterMatchMode.IN}

Re: Multiselect filter not working for an array

Posted: 05 Nov 2022, 04:57
by ssaha
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"
/>

Re: Multiselect filter not working for an array

Posted: 05 Nov 2022, 15:24
by Melloware