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

Option to render trees expanded #141

Closed
zernyu opened this issue Apr 4, 2012 · 9 comments
Closed

Option to render trees expanded #141

zernyu opened this issue Apr 4, 2012 · 9 comments

Comments

@zernyu
Copy link

zernyu commented Apr 4, 2012

It would be awesome if we could supply an option in the grid constructor to set the default depth of a tree to be expanded when trees are first rendered. The project I am working on has a few requirements that the trees be expanded by default and I have to currently traverse the tree and expand the nodes manually :(

@mikerobi
Copy link

mikerobi commented May 3, 2012

I would prefer passing an expandIf function to the column plugin. If the function returns true for a row, the node and and all of its ancestors are rendered expanded.

@zernyu
Copy link
Author

zernyu commented May 3, 2012

+1

That's a much better idea.

@mikerobi
Copy link

mikerobi commented May 4, 2012

I realize that in my first comment, I had things backwards. expandIf will only be called when a row is inserted, thus its ancestors have already been expanded.

Determining the depth of a node from within the expandIf function could still require walking up the tree to count nodes. I suggest that it receives the depth as its second argument.

@zernyu
Copy link
Author

zernyu commented May 4, 2012

Or the nodes can have a depth property that the expandIf function can check.

@mikerobi
Copy link

mikerobi commented May 5, 2012

If you are using lazy loading, there may be situations where the depth of a record is unknown unless you walk up the tree.

@zernyu
Copy link
Author

zernyu commented May 16, 2012

Doh. I'm an idiot ;)

@ghost
Copy link

ghost commented May 22, 2012

I've taken a stab at this with #172. Open to comments for the time being.

Thanks @mikerobi for the idea of conditionalizing it. Initially I was very reluctant to entertain the idea of blanket auto-expand, just because I don't like tempting people to use it without considering the consequences (especially if it's being used with a non-memory store, i.e. going back to the server for each request for children).

However, it is a request that comes up fairly often, and this also gave me the opportunity to also allow "preserving" of expanded states when rows get unrendered and re-rendered later (either from scrolling or observer-induced remove/insert operations).

@zernyu
Copy link
Author

zernyu commented May 25, 2012

Awesome, I will test this out now. I've been running into more and more problems with reexpanding trees after refreshing them.

@ghost
Copy link

ghost commented Jun 4, 2012

Closing this now, since #172 has been merged. Thanks @swiftdemise for the additional feedback and tire-kicking.

@ghost ghost closed this as completed Jun 4, 2012
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants