Dropdown Custom Filter


#1

I have a dropdown that show a list of employees that also have department and role for each one.
I’ll like to have a custom filter for the dropdown that will search in both name, dept and role of each employee but I’ve read the code and I don’t see the ability to do that.

There is a remote loading ability but my data is small, few hundred employees at most, so it will be much much faster doing it locally.

I’ve implemented this myself by passing a function in fullTextSearch option and call it from dropdown but I’ll like to know if that is the right way to do so or should I use othe rmethod? I’ll be happy to create a PR for that, for now this is the change snippet:

        module.verbose('Searching for matching values', searchTerm);
        $item
          .each(function(){
            var
              $choice = $(this),
              text,
              value
              ;
            if (typeof settings.fullTextSearch === 'function') {
                text = String(module.get.choiceText($choice, false));
                value = String(module.get.choiceValue($choice, text));
                if (settings.fullTextSearch(searchTerm, text, value)) {
                    results.push(this);
                }

                return true;

            }