0
votes

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

1 Answers

0
votes

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