gridOptions not updating when columnDefs and data has changed in parent scope
In the gridController I'm initializing gridOptions with data from the secondParentController:
$scope.gridOptions = GRID_CONFIG;
//set the pagingOptions which is bound to $scope $scope.gridOptions.pagingOptions = $scope.pagingOptions;
$scope.gridOptions.columnDefs = $scope.columnDefs;
Here GRID_CONFIG contains common grid configuration options which includes 'data: model.data'. Now when the user clicks on a button the secondParentController updates columnDefs to an array. This is not reflected in the grid. Is there any workaround to this?
In secondParentController:
$scope.$on('gridModelChanged', function () { $scope.model.data = $scope.$parent.model.clientGroup.clientList; $scope.columnDefs = $scope.$parent.model.clientGroup.columnDefs; });
Setting those properties to strings will have ng-grid watch them for changes. If you do the following, I believe it should work:
$scope.gridOptions = GRID_CONFIG; $scope.gridOptions.pagingOptions = 'pagingOptions'; $scope.gridOptions.columnDefs = 'columnDefs';
Presuming this solution has resolved the issue, closing.