AngularJS:从外部方法更新UI Grid的过滤器

neo*_*row 5 angularjs angular-ui-grid

我希望能够在我的控制器中设置/更新一个值,然后在网格中进行过滤.目前,在我输入网格然后触发filterChanged事件之前,不会更新对过滤器的更改.知道我如何自动过滤网格配置中的数据或至少做一次硬刷新?

感谢您的帮助.

这是AngularJS UI Grid网站上稍微修改过的Plunker. http://plnkr.co/edit/pgX31NT3Ry3XllZ3JO2B?p=preview

这是我在columnDefs部分中的当前过滤器定义:

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

r0m*_*m4n 4

当您定义 时gridOptions,请使用以下内容设置 gridAPI 变量:

onRegisterApi: function(gridApi){
    $scope.gridApi = gridApi;
},
Run Code Online (Sandbox Code Playgroud)

然后在更新函数中运行以下命令来重新评估过滤条件:

$scope.gridApi.grid.refresh()
Run Code Online (Sandbox Code Playgroud)

正如 @Conan 提到的,发布了一个重大更新,并且这只适用于

有一个错误,这在 3.2.x 上不起作用。已在 3.1.x 和 4.x 中测试并工作 http://plnkr.co/edit/YbgV9YZrWCZE4cc3qGru?p=preview