Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: custom filter behaviors #1007

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Feature: custom filter behaviors #1007

wants to merge 1 commit into from

Conversation

ancms2600
Copy link

I have a list of strings in the format:

`${AccountName} (${AccountId})`

image

In one case, there were two matches for "L1 Application" but one of them had a hyphen in the account name, which caused it not to match.

I wanted a simple way to sanitize the filter candidate before the match was performed. In my case, I have it remove all non-alphaNumeric characters, like so:

$('#filterByAccount').multiselect({
    enableFiltering: true,
    filterBehavior: ({text}) => text.replace(/[^a-z0-9]+/gi, ' '),
    // ...
});

As a result, it now matches both results, as expected (see image above).

Others could theoretically use this function to do even more, such as modify what is matched on (e.g., starts-with could easily be performed by returning filter candidates that contain starting parts only, and this function could be rotated between a set of possible filter candidate generators depending on the search mode.)

see also: #803 #408

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant