-
Notifications
You must be signed in to change notification settings - Fork 99
Support Adding new nodes #147
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
Comments
Same, I love using the package, but it would be really useful if I could add children to the tree without changing the nodes prop value provided. I have tried this, but it doesn't work :/ performNodeUpdate(
[
{
"id": 564827411,
"name": "Controller.php",
"children": [],
"state": {
"selected": false,
"expanded": false,
"favorite": false,
"deletable": false,
}
}
]
); const performNodeUpdate = (newChildren: VirtualizedTreeNodeType[] = []) => {
/**
* Manipulating implementation of updateNode selector from https://github.com/diogofcunha/react-virtualized-tree/blob/master/src/selectors/nodes.js#L77
* Also see: https://github.com/diogofcunha/react-virtualized-tree/blob/master/src/renderers/Deletable.js
* https://github.com/diogofcunha/react-virtualized-tree/blob/master/index.d.ts#L141
* https://github.com/diogofcunha/react-virtualized-tree/blob/master/src/renderers/Favorite.js
*
* Original implementation:
*
* props.nodeProps.onChange({
* ...updateNode(props.nodeProps.node, {expanded: !isExpanded}),
* index: props.nodeProps.index,
* });
*
*/
props.nodeProps.onChange({
index: props.nodeProps.index,
node: {
...props.nodeProps.node,
children: [
...props.nodeProps.node.children,
newChildren,
],
state: {
...props.nodeProps.node.state,
expanded: hasChildren ? !isExpanded : false,
selected: true,
},
},
type: UPDATE_TYPE.UPDATE,
});
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I see that UPDATE_TYPE includes ADD option to add a new node,
but how is it supported in the TreeView?
I see there is support for DELETE and UPDATE, but I dont see any implementation for ADD, is that true?
The text was updated successfully, but these errors were encountered: