0
votes

im using the ui-grid and have a input Box. I want to bind the input box as a filter to the column in the grid. I dont want to use the buildin textbox in the ui-grid.

can anyone help ?

2

2 Answers

2
votes
  1. in gridOption.columnDefs, set the column you want to filter, for example: { field: 'gender', enableFiltering: false } to disable inline filter
  2. get the grid state using gridApi
  3. find your column in state.columns and add your filter to it.
  4. restore grid state which is to apply your filter to the grid I made you a plunker. http://plnkr.co/edit/p878r7GsFig1goX5rroK?p=preview
0
votes

As I was looking for the same kind of things, sunz7 answer helped me, but then, you can improve it, as in this state, the plunker provided by sunz7 do not allow to change the search. A new click on the button will trigger a search within the previous search.

And as bonus, an empty search field will remove the filter, just by changing

$scope.state.columns[1].filters.push({term: $scope.genderFilter});

by

$scope.state.columns[1].filters[0] = {term: $scope.genderFilter || '*'};

http://plnkr.co/edit/HN9kc9IbHdi9YH4OBUS7?p=preview

This fork of the plunker fix that.