ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Multiple Grid each with expand

Open redapplewithleaves opened this issue 12 years ago • 8 comments

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();
    }

redapplewithleaves avatar Nov 11 '14 23:11 redapplewithleaves

@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).

PaulL1 avatar Nov 12 '14 21:11 PaulL1

Hi @redapplewithleaves Can you please share a fiddle for the issue.

jpuri avatar Nov 13 '14 04:11 jpuri

Hello @jpuri, Jsfiddle was not cooperating.

Here is the Plunkr: http://plnkr.co/edit/u2N2emKRwaKQUm7dh9Ya?p=preview

redapplewithleaves avatar Nov 13 '14 15:11 redapplewithleaves

On that note, I found another strange bug on the same plunkr. First Grid:

  1. Expand a few rows
  2. Scroll Down a few times
  3. 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. image Or Empty Spaces: image

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: image

Note: Without expanding the rows, the issue does not occur.

redapplewithleaves avatar Nov 13 '14 17:11 redapplewithleaves

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();
}

kevin-sage avatar Dec 05 '14 19:12 kevin-sage

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.

redapplewithleaves avatar Dec 08 '14 17:12 redapplewithleaves

Hey @PaulL1,

Please close this issue.

jpuri avatar Dec 15 '14 11:12 jpuri

Thanks @jpuri

PaulL1 avatar Dec 15 '14 18:12 PaulL1