var app = angular.module('app', ['ngAnimate', 'ngTouch', 'ui.grid', 'ui.grid.grouping' ]);

app.controller('MainCtrl', ['$scope', '$http', '$interval', '$timeout', function ($scope, $http, $interval, $timeout, uiGridGroupingConstants ) {
  $scope.gridOptions = {
    enableFiltering: true,
    treeRowHeaderAlwaysVisible: false,
    columnDefs: [
      { name: 'name' },
      { name: 'state', grouping: { groupPriority: 0 }, sort: { priority: 0, direction: 'desc' }, width: '35%', cellTemplate: '<div><div ng-if="!col.grouping || col.grouping.groupPriority === undefined || col.grouping.groupPriority === null || ( row.groupHeader && col.grouping.groupPriority === row.treeLevel )" class="ui-grid-cell-contents" title="TOOLTIP">{{COL_FIELD CUSTOM_FILTERS}}</div></div>' },
    ],
    onRegisterApi: function( gridApi ) {
      $scope.gridApi = gridApi;
    }
  };

  $http.get('http://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json')
    .success(function(data) {
      for ( var i = 0; i < data.length; i++ ){
        data[i].state = data[i].address.state;
      }
      delete data[2].age;
      $scope.gridOptions.data = data;
      $timeout($scope.expandAll);
    });

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

  $scope.collapseAll = function(){
    $scope.gridApi.treeBase.collapseAllRows();
  };
  
  $scope.triggerBug = function(){
    $timeout($scope.collapseAll, 100);
    $timeout($scope.expandAll, 500);
  }
  
}]);
.grid {
  width: 500px;
  height: 400px;
}
<!doctype html>
<html ng-app="app">
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular-touch.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular-animate.js"></script>
    <script src="http://ui-grid.info/release/ui-grid-unstable.js"></script>
    <link rel="stylesheet" href="http://ui-grid.info/release/ui-grid-unstable.css" type="text/css">
    <link rel="stylesheet" href="main.css" type="text/css">
  </head>
  <body>

<div ng-controller="MainCtrl">
  <button type="button" class="btn btn-success" ng-click="expandAll()">Expand All</button>
  <button type="button" class="btn btn-success" ng-click="collapseAll()">Collapse All</button>
  <button type="button" class="btn btn-success" ng-click="triggerBug()">Trigger Bug!</button>
  <div ui-grid="gridOptions" ui-grid-grouping class="grid"></div>
</div>


    <script src="app.js"></script>
  </body>
</html>