ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

gridOptions not updating when columnDefs and data has changed in parent scope

Open sagar-ganatra opened this issue 12 years ago • 2 comments

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; });

sagar-ganatra avatar Jun 09 '14 13:06 sagar-ganatra

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';

linkmastr001 avatar Jun 13 '14 19:06 linkmastr001

Presuming this solution has resolved the issue, closing.

PaulL1 avatar Sep 04 '14 23:09 PaulL1