This is more of a question.
I am adding node programmatically, similar to here:
https://fritz-c.github.io/react-sortable-tree/storybook/index.html?selectedKind=Basics&selectedStory=Add%20and%20remove%20nodes%20programmatically&full=0&addons=0&stories=1&panelRight=0
Immediately after adding a node to the tree I need to find the path info which the item was inserted at (similar to clicking a button in the node and and getting the node/path ). What would be the recommended approach to getting this info?
Thanks!
Hi @29er. You can use the helper functions https://github.com/fritz-c/react-sortable-tree#data-helper-functions. to get the treeData and then find the node you just added (either by title or key) specifying getNodeKey prop might help :)
sorry for late response on this. but this is exactly my question. which utility function would give me the new path info of the node I just added ( if I were to use 'title' as my search term ) ? Can you give me an example using one of the helper functions ?
Thanks
Was also wondering the same thing. Can't find a built in function that would do this
if you were dragging I would use the onMoveNode callback which has a nextPath property.
However, programmatically adding nodes would be a little tricky. I would recommend using the generateNodeProps prop and adding an event handler to the node that binds the value path from the callback.
Hope that helps!
@wuweiweiwu can you please give an example of what you described?
"However, programmatically adding nodes would be a little tricky. I would recommend using the generateNodeProps prop and adding an event handler to the node that binds the value path from the callback."
i'm also trying to figure out how to get the nextPath from onMoveNode to pass to generateNodeProps.
Most helpful comment
sorry for late response on this. but this is exactly my question. which utility function would give me the new path info of the node I just added ( if I were to use 'title' as my search term ) ? Can you give me an example using one of the helper functions ?
Thanks