I'm a beginner to Angular and my knowledge of JavaScript is limited. I'm encountering an issue while trying to display data in ngGrid with the code below. Can you help me identify what's causing the problem?
Essentially, I am fetching data from a web service, transforming it (pivot), and then attempting to present it in a grid.
Please refer to the following:
app.js -> starting point
var konstruktApp = angular.module('konstruktApp', ['ngGrid']);
dataService.js -> web service call
'use strict';
konstruktApp.service('DataService', function DataService($http){
var callHttp = function(){
delete $http.defaults.headers.common['X-Requested-With'];
return $http.get("http://83.250.197.214/konstrukt.service/Konstrukt.SL.DummyBudgetService.svc/GetDummyBudgetData/");
};
return {
getDummyData: callHttp
};
});
ngGridController.js -> where the logic resides...
$scope.getData = DataService.getDummyData;
$scope.gridOptions = {data:'result'};
var getData = function() {
$scope.getData().then(function (response) {
var res = pivotData(response.data);
$scope.result = res.data.PivotedRows;
$scope.columns = res.cols;
console.log('from the success handler at ' + new Date());
}, function (reason) {
console.log('failed: ');
console.log(reason);
});
};
..and here is the logic that performs the "pivot" on the data
var pivotData = function(data) {
// Logic for pivoting the data goes here
};
plnkr: http://plnkr.co/edit/ZqC7696xGbUtuWGIvnYs?p=preview
EDIT: The data correlation between rows and columns seems correct, but there may be an issue with the data in the pivotedArray.PivotedRows array.