Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

function to expand all and close all rows in the tree structure #22

Open
arjunaria opened this issue Apr 5, 2019 · 7 comments
Open

Comments

@arjunaria
Copy link

I am looking any implementation that can help me achieve expand all and collapse all function in the tree. Currently we do pass them as props which is just one time.how can this be achieved in the current code..

Also i would want to expand upto a certain parent node when i pass the parent id. is that feasible with the current one.?

@maheshsenni
Copy link
Owner

Have you tried expandAll in component options?

Expanding up to a certain node is not possible in the current implementation and I am afraid it is too specialized a functionality to add provide as an option to do it. Couple of ways it can be implemented though - 1) an option line expandUntil which would accept an id and would expand all nodes until a node with the specified id is encountered. 2) accept a list of parent node ids which should be expanded. Second option would be the easiest to implement based on the current rendering code.

@arjunaria
Copy link
Author

thanks for the reply mahesh,
I did try the expandAll option. this only works for the first load and though mapped to a state the state change is not picked up by the component.any thoughts on this.

And regarding the expanding upto certain node, i will work on the option 2 which you have suggested.

@maheshsenni
Copy link
Owner

I don't quite understand the state change part - are you trying to pass the expandAll property from your application state? Is the value of the expandAll property itself changing via state?

@maheshsenni
Copy link
Owner

@arjunaria is this still an issue for you?

@arjunaria
Copy link
Author

yes this is still does not seem to work seamlessly. my implementation is as below. I have 2 buttons to handle the functionality
expand all
close all

this.state = {

expandStatus: true,
}

openTreeView() {
this.setState({ expandStatus: true });
React.useState();
this.setState({ counter: Math.random() });
}

closeTreeView() {
this.setState({ expandStatus: false });
this.setState({ counter: Math.random() });
React.useState();
}

shouldComponentUpdate(nextState) {
// adding this as scroll causes re-render
// checking just expanded rows for now, can add
// 'data' in future
const shouldUpdate = nextState.expandStatus !== this.expandStatus
return true;
}

@arjunaria
Copy link
Author

Hi Mahesh, did you get a chance to review it.

Though expand and collapse works on certain occasions

  1. Tree is expanded , the. I close any tree node or close the ultimate parent. Now i do expand all and it does not work

@arjunaria
Copy link
Author

Also let us say there are cyclic redundancies. In this case when I close or open a node then all the nodes with the same I'd collapse/expand.

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

No branches or pull requests

2 participants