Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs ui网格过滤器取消事件_Angularjs_Ng Grid_Angular Ui Grid - Fatal编程技术网

Angularjs ui网格过滤器取消事件

Angularjs ui网格过滤器取消事件,angularjs,ng-grid,angular-ui-grid,Angularjs,Ng Grid,Angular Ui Grid,嗨,我使用的是angular ui网格,网格中有过滤器和分组 默认情况下,我使用以下命令展开所有行 $scope.expandAll = function(){ $scope.gridApi.treeBase.expandAllRows(); }; $timeout(function() { $scope.expandAll(); }, 500); 现在,如果用户筛选数据中不可用的任何列 然后删除或取消,它不会自动展开 如上图所示 当用户清除或取消筛选数据时,我需

嗨,我使用的是angular ui网格,网格中有过滤器和分组 默认情况下,我使用以下命令展开所有行

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

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

现在,如果用户筛选数据中不可用的任何列

然后删除或取消,它不会自动展开

如上图所示

当用户清除或取消筛选数据时,我需要所有行自动展开

我发现有一个事件过滤器已更改,但我不知道如何使用它

我正在使用以下plunkr进行测试


谢谢

将onRegisterApi方法修改为以下内容

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);
    }
  });
}

请参见plunkr

我只需执行$timeout(function(){$scope.expandAll();},500);在我的filterChanged函数中