Smart-Table icon indicating copy to clipboard operation
Smart-Table copied to clipboard

Is there are a way for a strict search in custom directive?

Open kyrodabase opened this issue 8 years ago • 6 comments
trafficstars

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

kyrodabase avatar Jan 13 '17 14:01 kyrodabase

you have on the documentation website section "strict mode filtering"

lorenzofox3 avatar Jan 13 '17 15:01 lorenzofox3

I have seen it, none of the examples include a way to do it in custom directive.

kyrodabase avatar Jan 13 '17 15:01 kyrodabase

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

lorenzofox3 avatar Jan 13 '17 15:01 lorenzofox3

Thanks!

kyrodabase avatar Jan 13 '17 15:01 kyrodabase

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 ?

lorenzofox3 avatar Jan 17 '17 19:01 lorenzofox3

I think global filter would be an option, at least in our case.

kyrodabase avatar Jan 19 '17 09:01 kyrodabase