如何在ui-grid中使用刷新方法?

时间:2014-10-29 15:15:17

标签: javascript angularjs angular-ui-grid

我正在尝试更新我的ui-grid的columDefs中的可见性选项。更新值后,我需要刷新我的ui-grid。从我的控制器刷新网格的方法是什么?

3 个答案:

答案 0 :(得分:37)

访问此页面:

http://ui-grid.info/docs/#/api/ui.grid.class:GridApi

在实例化gridApi之后,您只需调用:

//instantiate (not so obvious)
// whatever scope attribute your binding to gridOptions
$scope.gridOptions = {
  onRegisterApi: function(gridApi){ $scope.gridApi = gridApi;}
}
//then later
$scope.gridApi.core.refresh();

希望有所帮助!

答案 1 :(得分:8)

根据您的需要,您可以更改以下ui-grid选项

NSObject

答案 2 :(得分:0)

您可以使用 $ scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN);修改列defs然后刷新网格后的方法。

有关的更多详细信息 http://ui-grid.info/docs/#!/api/ui.grid.service:uiGridConstants#properties_datachange