Smart-Table
Smart-Table copied to clipboard
Is there are a way for a strict search in custom directive?
Hi,
Great lib! :)
Is there are a way to match the exact search term instead of a substring? Currently if I search for ID = 4, the search function returns ID = 4 and ID = 4000, ID = 4001 etc. Here is a code snippet:
` .directive("customWatchFilters", function () {
return {
restrict: "A",
require: "^stTable",
link: function (scope, element, attrs, ctrl) {
scope.$watchCollection(attrs.customWatchFilters, function (filters) {
ctrl.tableState().search.predicateObject = {};
angular.forEach(filters, function (val, filter) {
if (angular.isUndefined(val) || val === null) {
return;
}
ctrl.search(val.toString(), filter);
});
ctrl.pipe();
});
}
};
});`
Please advise
you have on the documentation website section "strict mode filtering"
I have seen it, none of the examples include a way to do it in custom directive.
you are right, it might be easier to pass a stricmode flag here to follow the same signature than angular filter filter.
You can submit a PR, or I ll do it over the week end
Thanks!
Hi, I looked into it and found out that the strict flag you pass to the angular filter filter would be global meaning you can not do a strict search on a column and a regular search on another, unless you use a custom filter. What do you think ?
I think global filter would be an option, at least in our case.