I've been trying for hours to get this working. I load a few grids organized by data category, then I'd like to have another grid at the bottom of the page with all data category agnostic. The grids are hidden at first, so users can click on each individual category to see the respective grid, so I need to extract the api for each grid and call handleWindowResize() on them when they are clicked.
I think the problem is that onRegisterApi is not executing for the allData grid. Everything else works like a charm.
$scope.globalColumnDefs = [//column definitions here];
$scope.dataList = {};
$scope.allData = [];
$scope.gridOptions = [];
$scope.gridApis = [];
dataFactory.getData().success(function (data) {
$scope.dataList = data.dataCategories;
//set up each grid for data categories
angular.forEach($scope.dataList, function (value) {
$scope.allData = $scope.allData.concat(value.items);
$scope.gridOptions.push({
data: value.items,
minRowsToShow: 25,
showColumnFooter: true,
enableFiltering: true,
columnDefs: $scope.globalColumnDefs,
onRegisterApi: function (api) {
$scope.gridApis.push(api);
}
});
});
//set up the allData grid
$scope.gridOptions.push({
data: $scope.allData,
minRowsToShow: 25,
showColumnFooter: true,
enableFiltering: true,
columnDefs: $scope.globalColumnDefs,
onRegisterApi: function (api) {
console.log("Regiestering API");
$scope.gridApis.push(api);
}
});
});
the console.log statement never fires (but it will if I put it in the first foreach loop). I started out with the loops combined and simply changing the data of the gridOptions object each time, but that didn't work. I also tried moving the allData to a new grid variable with new grid options with no luck.
Why isn't onRegisterApi firing for the allData grid??