I am trying to update visibility option in the columDefs of my ui-grid. After updating the value I need to refresh my ui-grid. What is the way to refresh my grid from my controller?
Asked
Active
Viewed 7.1k times
3 Answers
41
Visit this pages:
- GetAPI - http://ui-grid.info/docs/#/api/ui.grid.class:GridApi
- Specific API - http://ui-grid.info/docs/#/api/ui.grid.core.api:PublicApi
http://ui-grid.info/docs/#/api/ui.grid.class:GridApi
After having instantiated your gridApi, you can just call:
//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();
Hope that helps!
-
I had a ui-grid with a total row and when some amount in a cell was updated from my code, the totals for that cell didn't update. This solution solved the issue. – Manuel Rivera Nov 25 '16 at 21:54
-
4Answer needs expanding to explain how to instantiate gridApi. – BarrySW19 Nov 30 '16 at 12:08
-
But such expanding would require quite another question. – Thor Hovden Jun 13 '18 at 13:50
8
Depending on your need you can change the following ui-grid option
enableRowHashing:false

albert
- 8,112
- 3
- 47
- 63

Zdzislaw Kochanski
- 81
- 1
- 1
-
1I'm only updating data in place, so no array length or other super smart grid watches were triggered, thus I had to ng-if the grid out of the DOM and insert it after. with `enableRowHashing:false` it's working now without ng-if. Thank you very much! – Aitch Sep 01 '16 at 15:22
0
You can use $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN); method after you modify the column defs and then refesh the grid .
More Details on http://ui-grid.info/docs/#!/api/ui.grid.service:uiGridConstants#properties_datachange