How to use refresh method in ui-grid?
Asked Answered
A

3

28

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?

Adkisson answered 29/10, 2014 at 15:15 Comment(0)
R
42

Visit this pages:

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!

Robbirobbia answered 13/2, 2015 at 19:21 Comment(3)
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
I
8

Depending on your need you can change the following ui-grid option

enableRowHashing:false

Ieyasu answered 25/5, 2016 at 17:3 Comment(1)
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
C
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

Computerize answered 24/6, 2020 at 10:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.