FooTable icon indicating copy to clipboard operation
FooTable copied to clipboard

Custom Filter UI Ignores Exact Match

Open msyhr opened this issue 7 years ago • 3 comments

Using a variation of this example with a multi-select and exact match = true, filter returns non-exact results.

http://fooplugins.github.io/FooTable/docs/examples/advanced/custom-filter-ui.html

$('#filter_by_a').on('change', function(){ filtering.addFilter('a_diameter', $(this).val, ['a_diameter']); filtering.filter(); }); <table id="bom_items" data-sorting="true" data-filtering="true" data-expand-first="false" data-filter-exact-match="true">

screen shot 2018-01-12 at 3 58 17 pm

However, when using the non-custom ui, the results are correct

screen shot 2018-01-12 at 4 00 32 pm

msyhr avatar Jan 12 '18 22:01 msyhr

The problem maybe is because the attr data-filter-exact-match only affect to change event on input search that provide FooTable, that is saved to filters with name 'search'

You can try a temporary solution, add " " to your query string in the function asigned to change's event ,like this:

$('#filter_by_a').on('change', function() {
    var queryString = '"' + $(this).val + '"';
    filtering.addFilter('a_diameter', queryString, ['a_diameter']);
    filtering.filter();
});

If you see the code, is the same, only add "

kip-13 avatar Jan 25 '18 14:01 kip-13

Sorry for drudging up an old topic but the temporary solution (which I also found in the docs) isn't working for me. I only need to exact filter on one custom filter. Selecting 'Admins' returns both 'Super Admins' and 'Admins'; else if (type === 'role') { if (selected !== self.defr) { self.addFilter('role', '"' + selected + '"', ['roles']); } else { self.removeFilter('role'); } } self.filter();

JAIC-be avatar Oct 07 '19 07:10 JAIC-be

@JAIC-be the problem is because the space is treated like an AND

By default the filtering component treats all whitespace as an AND operator [....]

Use the argument space in the addFilter method, see here

addFilter(nameOrFilter, query, columns, ignoreCase, connectors, space, hidden)

If doesnt work, you need to be explicit with the match evaluation, so use the exactMatch property, in the code you can see how this property works.

https://github.com/fooplugins/FooTable/blob/fba11d1d8ad4eb61913c7538b26283eab2d9d777/src/js/components/filtering/FooTable.Filtering.js#L564

kip-13 avatar Oct 07 '19 12:10 kip-13