Skip to content
This repository was archived by the owner on May 11, 2018. It is now read-only.

Conversation

@jantosi
Copy link

@jantosi jantosi commented Jul 14, 2015

Now a different comparator can be specified for each row field.
This sets the comparator argument in AngularJS' filter.
If this attribute is omitted, the table defaults to a false value -- which means lowercase substring matching. If a function name is given, we will try to resolve it from the local scope and pass it as a comparator.

This is particularly useful when creating your own strict filtering on a field containing similar values (ie. "Field Unit" and "Field Unit Manager"). In the default behaviour, selecting "Field Unit" from a dropdown would match rows with both of the types.

This also allows for some degree of extensibility, allowing users to create their own comparators (think fuzzy-matching!).

@acd10
Copy link

acd10 commented Jan 12, 2018

Can you give an example of how this can be implemented?

@jantosi
Copy link
Author

jantosi commented Jan 12, 2018

@acd10 This was some time ago, but having re-read this PR I believe this is how it works:

On each column definition, you can set filterComparator field to true, false, a function name or a function.

  • true means strict matching is enabled for this field
  • false goes back to default behaviour
  • function (or a function name) specifies a comparator function when calling $filter('filter')(itemsFilteredWithComparators, currentPattern, comparator). Useful for custom logic.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants