0

Hi I am using angular ui grid, I have filter and grouping in the grid I am expanding by default all rows using following

$scope.expandAll = function(){
    $scope.gridApi.treeBase.expandAllRows();
  };

 $timeout(function() {
    $scope.expandAll();
}, 500);

enter image description here

now if user filter on any column which is not available in data

enter image description here

And then remove or cancel, It does not expand automatically

enter image description here

It shows like above

I need all rows to expand automatically when user clear or cancel filter data

I found there is an event filterChanged, but I don't know how to use that

I am using following plunkr for testing

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

Thanks

1 Answer 1

0

Modify your onRegisterApi method to the following

onRegisterApi: function( gridApi ) {
  $scope.gridApi = gridApi;
  $scope.gridApi.core.on.filterChanged($scope, function() {        
    var grid = this.grid;
    var isfilterclear = true;
    angular.forEach(grid.columns, function( col ) {
      if(col.filters[0].term){
        isfilterclear = false;
      }
    });
    if(isfilterclear) {
        $timeout(function() {
            $scope.expandAll();
        },500);
    }
  });
}

see plunkr http://plnkr.co/edit/1FWDIe?p=preview

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

1 Comment

I just end up doing $timeout(function() {$scope.expandAll();},500); in my filterChanged function

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.