Multiple Grid each with expand
I have 2 expandable grid in the same controller and I have an expand and collapse all for both. However, both grid's expand and collapse button only functions for the second grid.
I know this is why, but is there a way to have each grid have its own expand and collapse button?
$scope.expandAllRows = function () {
$scope.gridApi.expandable.expandAllRows();
}
$scope.collapseAllRows = function () {
$scope.gridApi.expandable.collapseAllRows();
}
@jpuri, would you have time to look at this? Sounds like a scope issue - of the scopes overlapping, or perhaps the grid needs to be passed into the methods so we know which grid it's working against? (Many of the other features take the grid in as a parameter in their api).
Hi @redapplewithleaves Can you please share a fiddle for the issue.
Hello @jpuri, Jsfiddle was not cooperating.
Here is the Plunkr: http://plnkr.co/edit/u2N2emKRwaKQUm7dh9Ya?p=preview
On that note, I found another strange bug on the same plunkr. First Grid:
- Expand a few rows
- Scroll Down a few times
- Scroll Up a few times
The grid turns all weird. It has a lot of empty space. If you scroll down up and down enough, it won't show you any data anymore.
Or Empty Spaces:

I thought it was a loading issue at first, but I waited and nothing shows up.
The second grid works better, but eventually it also breaks:

Note: Without expanding the rows, the issue does not occur.
You are assign both gridApi's to the same scope variable:
$scope.gridOptions.onRegisterApi = function(gridApi){ $scope.gridApi = gridApi; };
$scope.gridOptions2.onRegisterApi = function(gridApi){
$scope.gridApi = gridApi;
};
try something like:
$scope.gridOptions.onRegisterApi = function(gridApi){
$scope.gridApi1 = gridApi;
};
$scope.gridOptions2.onRegisterApi = function(gridApi){
$scope.gridApi2 = gridApi;
};
$scope.expandAllRows = function() {
$scope.gridApi1.expandable.expandAllRows();
$scope.gridApi2.expandable.expandAllRows();
}
$scope.collapseAllRows = function() {
$scope.gridApi1.expandable.collapseAllRows();
$scope.gridApi2.expandable.collapseAllRows();
}
Yes! That works out wonderfully. Thank you!!
From: kevin-sage [mailto:[email protected]] Sent: Friday, December 05, 2014 11:15 AM To: angular-ui/ng-grid Cc: Angelina Adidjaja Subject: Re: [ng-grid] Multiple Grid each with expand (#2066)
You are assign both gridApi's to the same scope variable:
$scope.gridOptions.onRegisterApi = function(gridApi){ $scope.gridApi = gridApi; };
$scope.gridOptions2.onRegisterApi = function(gridApi){
$scope.gridApi = gridApi;
};
try something like:
$scope.gridOptions.onRegisterApi = function(gridApi){
$scope.gridApi1 = gridApi;
};
$scope.gridOptions2.onRegisterApi = function(gridApi){
$scope.gridApi2 = gridApi;
};
$scope.expandAllRows = function() {
$scope.gridApi1.expandable.expandAllRows();
$scope.gridApi2.expandable.expandAllRows();
}
$scope.collapseAllRows = function() {
$scope.gridApi1.expandable.collapseAllRows();
$scope.gridApi2.expandable.collapseAllRows();
}
— Reply to this email directly or view it on GitHubhttps://github.com/angular-ui/ng-grid/issues/2066#issuecomment-65839336.
Hey @PaulL1,
Please close this issue.
Thanks @jpuri