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?
How to use refresh method in ui-grid?
Asked Answered
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. –
Valedictorian
Answer needs expanding to explain how to instantiate gridApi. –
Worsham
But such expanding would require quite another question. –
Kildare
Depending on your need you can change the following ui-grid option
enableRowHashing:false
I'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! –
Gorden 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
© 2022 - 2024 — McMap. All rights reserved.