Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand All/Collapse ALL Problem with Tree View #3399

Closed
dereklin opened this issue May 1, 2015 · 10 comments
Closed

Expand All/Collapse ALL Problem with Tree View #3399

dereklin opened this issue May 1, 2015 · 10 comments
Assignees
Milestone

Comments

@dereklin
Copy link

dereklin commented May 1, 2015

This issue happens both in the tutorial: http://ui-grid.info/docs/#/tutorial/215_treeView

Or in my plunker: http://plnkr.co/edit/MwhZMkAeioxceQtbChN1?p=preview

When you manually expand individual sub-trees, the Master Tree still shows the + sign. Instead, it should show the - sign, since all sub-trees have been expanded.

Vice Versa for Collapse ALL.

@PaulL1
Copy link
Contributor

PaulL1 commented May 16, 2015

Yes, there isn't a check as to whether every tree node is expanded, it drives off whether you clicked expand all or programatically called expand all.

I'm not keen to write a check as to whether every node is expanded - that would get expensive. But I would agree that (I think like grouping) if you have expanded all and you collapse something, then expandAll should toggle back to false.

@PaulL1 PaulL1 self-assigned this May 16, 2015
@PaulL1 PaulL1 added this to the 3.1 milestone May 16, 2015
PaulL1 added a commit to PaulL1/ng-grid that referenced this issue May 16, 2015
@PaulL1 PaulL1 closed this as completed in 394a919 May 16, 2015
PaulL1 added a commit that referenced this issue May 16, 2015
Fix(treeView): fix #3399 when collapse row expandAll should be unset
@c0bra c0bra removed the in progress label May 16, 2015
PaulL1 added a commit to PaulL1/ng-grid that referenced this issue May 16, 2015
@dereklin
Copy link
Author

When I expand all sub-trees, the master expand/collapse still shows +. It should show - because all sub-trees are already expanded. I might have missed it somewhere in your message. Did you say fixing this will be too expensive and therefore, it won't be fixed or changed?

@PaulL1
Copy link
Contributor

PaulL1 commented May 16, 2015

Yes. It would mean iterating over the entire tree on every digest cycle to see whether or not every cell is expanded. If we have a very large data set this will be expensive. Most applications don't do this - you only go to a - if someone explicitly clicks the button (or, in our case, calls expand all programatically).

@dereklin
Copy link
Author

Is there an option to hide the master expand/collapse button?

And would it be feasible to keep a tally for number of expanded/collapsed sub-trees on each expand/collapse action, and then just compare the tally with the total number of sub-trees to show/hide the master expand/collapse button?

For now, I think I can just use css to hide the master expand/collapse button.

@PaulL1
Copy link
Contributor

PaulL1 commented May 17, 2015

There is not currently an option to hide the button.

@dereklin
Copy link
Author

@PaulL1 This is actually fixed! I thought you said it would be too expensive to fix... Anyways, it's great. But with the new changes, my decorator is broken, that's a different story...

@PaulL1
Copy link
Contributor

PaulL1 commented May 25, 2015

Yeah, I did it in a different way that didn't require polling/binding, so performance impact is less.

Sent from my iPhone

On 26 May 2015, at 10:42 am, dereklin notifications@github.com wrote:

@PaulL1 This is actually fixed! I thought you said it would be too expensive to fix... Anyways, it's great. But with the new changes, my decorator is broken, that's a different story...


Reply to this email directly or view it on GitHub.

@tringuyenminh92
Copy link

how to know all rows are expanded after calling $scope.gridApi.treeBase.expandAllRows() method?
Because i need to call $scope.gridApi.core.scrollTo after calling expandAllRows. but it shown error message:
Error: grid.treeBase.tree.forEach is not a function
service.expandAllRows@http://localhost:51358/Scripts/angular/ui-grid.js:24508:9
service.initializeGrid/publicApi.methods.treeBase.expandAllRows@http://localhost:51358/Scripts/angular/ui-grid.js:24090:17

But if i let it loaded data and expanded. After that some seconds, i click button to call scrollTo method.
it will work.

@mattaGIT
Copy link
Contributor

None of the above worked for me for all of my grid use cases.

        $scope.gridApi.grid.registerDataChangeCallback(function() {
            if($scope.gridApi.grid.treeBase.tree instanceof Array){
                $scope.gridApi.treeBase.expandAllRows();
            }

        });

The following works in every case I have tested. DataChangeCallback is called twice (for some unknown reason) on initial page load. The first time, gridApi.grid.treeBase.tree is an object which causes the issue with gridApi.grid.treeBase.tree.forEach above:

@ramseyfeng
Copy link

@PaulL1, has this issue been fixed already?
I think you only fixed one way: unset expandAll icon when collapse some row, correct?
What about the other way? like you manually expand every rows one by one, will the the expandAll icon be synchronized?
I saw previously you have answered it would be expensive and you won't like to fix it.
But from your last reply, you said it has been fixed it, did you mean you have fixed this way as well? Or you only fix one of the scenario: "unset expandAll icon when collapse some row"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants