Here is the structure of my array:
$scope.ebObjArr = [{key: 'val', monthsArray: [{myDate:'',}]},{myDate:'',}]
The monthsArray
is responsible for populating the sub-grid. I am struggling to figure out how to populate data in the sub-grid.
This is what I have tried:
for (let i = 0; i < $scope.ebObjArr.length; i++) {
$scope.ebObjArr.monthsArray[i].subGridOptions = {
columnDefs: [{ name: "Month", field: "myDate" }, { name: "Cost", field: "totalCost" }, {name:"Units consumed", field : "unitsConsumed"}],
data: $scope.ebObjArr[i].monthsArray
}
}
I also attempted this approach:
for (let i = 0; i < $scope.ebObjArr.length; i++) {
for (let j = 0; j < $scope.ebObjArr[i].monthsArray[j].length; j++) {
$scope.ebObjArr[i].monthsArray[j].subGridOptions = {
columnDefs: [{ name: "Month", field: "myDate" }, { name: "Cost", field: "totalCost" }, { name: "Units consumed", field: "unitsConsumed" }],
data: $scope.ebObjArr[i].monthsArray[j]
}
}
}
In this example, I'm only using the MainCtrl
: .