I want to refresh the data of the ng-grid after an edit or add new data to the database. I tried the solution set forth in this page https://github.com/angular-ui/ng-grid/issues/39 . There are no errors displayed on the console to indicate that there is a problem. However, when it trigger the function all i got was a blank data from the ng-grid and all previous data were not being displayed anymore. What did i missed? Need your help. Thanks in advance.
Here is the function
self.fetchDataCenter = function() {
setTimeout(function(){
$http({
url:'api/centers',
type:'GET'})
.success(function(dCenter) {
$scope.centers = dCenter;
if (!$scope.$$phase) {
$scope.$apply();
}
});
}, 3000);
};
$scope.mySelectionsCenters = [];
$scope.gridCenters = { data: 'centers',
filterOptions: $scope.filterOptionsCenters,
selectedItems: $scope.mySelectionsCenters,
afterSelectionChange: function() {
$scope.itemsCC = $scope.mySelectionsCenters;
},
multiSelect: false,
columnDefs: [{field:'cost_center', displayName:'Cost Center'}]
};