You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to know if it's possible to add a property to customize the search function.
At the moment, the search is strict and the results must correspond exactly to the string entered in the search box.
What I'd like is if the user types several terms separated by spaces, then I'll search for each of the terms in the results without the position being important.
Example: Values:
[ 'Apple', 'Apple Pie', 'Apple tea', 'Pine Apple' ]
If I search for: “ppl pi” = No results
Expected result: 'Apple Pie' + 'Pine Apple'
Here is the filter function that I would like to implement :
constonSearchChange=(search)=>{if(!search)returnprops.multiselect_options;// If no search term, return all options// Normalizes a string to ignore accentsconstnormalize=str=>str.normalize("NFD").replace(/[\u0300-\u036f]/g,"");// Divides the search into several partsconstqueryParts=normalize(search).trim().toLowerCase().split(/\s+/);console.log(queryParts);// Filter options by individual termsletret=props.multiselect_options.filter(option=>{constnormalizedOption=normalize(option.name).toLowerCase();returnqueryParts.every(part=>normalizedOption.includes(part));});console.log(ret);returnret;}
The text was updated successfully, but these errors were encountered:
Hello,
I'd like to know if it's possible to add a property to customize the search function.
At the moment, the search is strict and the results must correspond exactly to the string entered in the search box.
What I'd like is if the user types several terms separated by spaces, then I'll search for each of the terms in the results without the position being important.
Example:
Values:
[ 'Apple', 'Apple Pie', 'Apple tea', 'Pine Apple' ]
If I search for: “ppl pi” = No results
Expected result: 'Apple Pie' + 'Pine Apple'
Here is the filter function that I would like to implement :
The text was updated successfully, but these errors were encountered: