I am using ui-grid in my project, for ui-grid configurations i am setting grid data, like below:
$scope.gridOptions ={
data : $scope.data,
columnDef:$scope.couumnDefs
};
I am making service call here and i am getting grid from DB,
myService.getData().then(function(data) {
var status = data.status;
if (status == 0) // success
{
$scope.data= data.gridData;
$scope.columnDef= data.gridCoulmunDef;
}
}, function(errorMessage) {
$scope.error = errorMessage;
});
But grid data is not updating, and i want to do some modification in $scope.data, but it is not updating, but here is missing the main concept of angular two way data binding
can any one suggest the what i need to do or i made any wrong please.
Thanks in advance !!!!
I've had to solve this in a couple of different projects, and this method works for me:
Restangular.all("block_sets/"+<%= params[:id] %> + "/addblock").customPOST(postParams ).then(function (data) { $scope.gridOptions.data = _.map(data.array, function (d) { return { exampleheader: d.exampledata, resource: d }; }); }).then(function() { $scope.gridApi.grid.modifyRows($scope.gridOptions.data); $scope.gridApi.core.refresh(); });
Note that I'm using Restangular with Rails4. The trick is to complete the application to the data set in GridOptions, then call modifyRows() and refresh().