5

I would like to be able to set/update a value in my controller that is then filtered in the grid. Currently, the changes to the filter aren't updated until I type into the grid which then triggers the filterChanged event. Any idea of how I can automatically filter the data in my grid config or at least do a hard refresh?

Thank you for the help.

Here's a slightly modified Plunker from the AngularJS UI Grid website. http://plnkr.co/edit/pgX31NT3Ry3XllZ3JO2B?p=preview

Here's my current filter definition in the columnDefs section:

    { field: 'company', filter: {
    noTerm: true,
    condition: function(searchTerm, cellValue) {
      return cellValue == scope.term;
    }

1 Answer 1

4

When you define your gridOptions, set the gridAPI variable with the following:

onRegisterApi: function(gridApi){
    $scope.gridApi = gridApi;
},

And then in your update function, run the following to re-evaluate the filter condition:

$scope.gridApi.grid.refresh()

As @Conan mentioned, a breaking update was released and this works only in

There was a bug and this doesn't work on 3.2.x. Tested and works in 3.1.x and 4.x http://plnkr.co/edit/YbgV9YZrWCZE4cc3qGru?p=preview

Sign up to request clarification or add additional context in comments.

5 Comments

Starting from version 3.2.1, refresh() no longer triggers the event that causes the grid to re-evaluate the custom filter function. Only putting text in the filter box triggers that event.
Updating the plunkr... I haven't experimented with the API in quite some time, there may be something else available now
Like you said, I think it is a issue with the new release of ui grid.
This is working for me in v.3.2.7, though the docs have not yet been updated.
@Guus working since 4.x for me. Updating the plunkr again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.