primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
6.9k stars 1.05k forks source link

Dropdown, ListBox, MultiSelect: support custom filter function #1448

Closed VsevolodGolovanov closed 2 years ago

VsevolodGolovanov commented 4 years ago

I'm submitting a ... (check one with "x")

[ ] bug report
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Codesandbox Case (Bug Reports)

Current behavior

Expected behavior Dropdown, ListBox and MultiSelect should support filterMatchMode="custom" with a custom filterFunction. Like DataTable and TreeTable do.

Minimal reproduction of the problem with instructions

Please tell us about your environment:

melloware commented 2 years ago

Fixed with: https://github.com/primefaces/primereact/issues/3039

Qcyk commented 2 years ago

Hi, I need add custom filter function in MultiSelect control. I need to use Regex to filter the data. I tried do this on two ways.

  1. I use filterTemplate as it is shown in documentation, but it is not possible to put regex value to option.filter().

const myFilterFunction = (event, options) => { let _filterValue = event.target.value; setFilterValue(_filterValue); options.filter(event); }

  1. In the filterTemplate I call my custom method (myFilterFunction) which change the options array in MultiSelect, but in this example I have a problem with filterring. When options array is empty I have a null instead of value in the MultiSelect control <InputText value={filterValue} ref={filterInputRef} onChange={(e) => myFilterFunction(e)} />

Is there any different way to use a custom filter method to filter data in MultiSelect control? I am grateful for the help. Regards,