I was dealing with the same problem, and I came up with a different solution, which IMHO is more "Angular-friendly." I used the ngModelOptions directive introduced in Angular 1.3. I replaced the default uiGrid filter template ("ui-grid / ui-grid-filter") with a custom one and set the ngModelOptions directive to input with a default value of 300 ms and 0 ms for blur.
This is a sample template based on the original ui-grid 3.0.5 template, where I also changed the default CSS classes with Bootstrap classes:
$templateCache.put('ui-grid/ui-grid-filter-custom', "<div class=\"ui-grid-filter-container\" ng-repeat=\"colFilter in col.filters\" ng-class=\"{'ui-grid-filter-cancel-button-hidden' : colFilter.disableCancelFilterButton === true }\">" + "<div ng-if=\"colFilter.type !== 'select'\"><input type=\"text\" class=\"input-sm form-control\" ng-model=\"colFilter.term\" ng-model-options=\"{ debounce : { 'default' : 300, 'blur' : 0 }}\" ng-attr-placeholder=\"{{colFilter.placeholder || ''}}\" aria-label=\"{{colFilter.ariaLabel || aria.defaultFilterLabel}}\"><div role=\"button\" class=\"ui-grid-filter-button\" ng-click=\"removeFilter(colFilter, $index)\" ng-if=\"!colFilter.disableCancelFilterButton\" ng-disabled=\"colFilter.term === undefined || colFilter.term === null || colFilter.term === ''\" ng-show=\"colFilter.term !== undefined && colFilter.term !== null && colFilter.term !== ''\"><i class=\"ui-grid-icon-cancel\" ui-grid-one-bind-aria-label=\"aria.removeFilter\"> </i></div></div>" + "<div ng-if=\"colFilter.type === 'select'\"><select class=\"form-control input-sm\" ng-model=\"colFilter.term\" ng-attr-placeholder=\"{{colFilter.placeholder || aria.defaultFilterLabel}}\" aria-label=\"{{colFilter.ariaLabel || ''}}\" ng-options=\"option.value as option.label for option in colFilter.selectOptions\"><option value=\"\"></option></select><div role=\"button\" class=\"ui-grid-filter-button-select\" ng-click=\"removeFilter(colFilter, $index)\" ng-if=\"!colFilter.disableCancelFilterButton\" ng-disabled=\"colFilter.term === undefined || colFilter.term === null || colFilter.term === ''\" ng-show=\"colFilter.term !== undefined && colFilter.term != null\"><i class=\"ui-grid-icon-cancel\" ui-grid-one-bind-aria-label=\"aria.removeFilter\"> </i></div></div>" + "</div>" );
The final step for this is to set this template in each column where you enable filtering:
columnDefs: [{ name: 'theName', displayName: 'Whatever', filterHeaderTemplate: 'ui-grid/ui-grid-filter-custom' }]
Unfortunately, I could not find a way to define this template globally, so I had to repeat the HeaderTemplate filter everywhere ... This is the only drawback, but on the other hand, you can also add additional filters to your custom template if you need.
Hope this helps!
source share