FooTable
FooTable copied to clipboard
Custom Filter UI Ignores Exact Match
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">
However, when using the non-custom ui, the results are correct
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 "
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 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