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?

Adriaan
  • 17,741
  • 7
  • 42
  • 75
orikoko
  • 881
  • 5
  • 15
  • 26

3 Answers3

41

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!

Nick
  • 1,174
  • 11
  • 20
Jose
  • 1,130
  • 3
  • 15
  • 25
8

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

enableRowHashing:false

albert
  • 8,112
  • 3
  • 47
  • 63
  • 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! – 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