react-checkbox-tree icon indicating copy to clipboard operation
react-checkbox-tree copied to clipboard

Allow to rename value directly from the tree

Open alessandronocera89 opened this issue 5 years ago • 3 comments

Hi guys, my request is the below: there is a way to change the single node value directly from the tree? I've searched and I've tried to change the value creating a localstorage service where I store the tree JSON and then pass all the changes by modal. When the callback is done, the localstorage is correctly update and also all files needed to render the tree, BUT, the tree inside the page still remain to old input. Only refreshing the page the new value appear. Render is ok when the callback is done.

So the new feature will be to change directly the node name, what do you think about it?

Thank you,

alessandronocera89 avatar Apr 23 '20 21:04 alessandronocera89

There is no way to rename a node within the component itself. That is a potential new feature to add.

However, you certainly can change the name of the nodes on-the-fly (such as through a modal as you describe) and update the component to reflect those changes. See this example.

You have to make sure that React knows that it needs to re-render the tree. The example above uses the standard setState to signal a change to React and thus trigger the Tree to redraw the labels.

jakezatecky avatar Apr 28 '20 22:04 jakezatecky

I understood, yep will be a good feature and yes, with play with setState and "straggling" a bit, I'm able to change on-the-fly the value and the label.

alessandronocera89 avatar Apr 29 '20 07:04 alessandronocera89

@alessandronocera89 would you tell how did you achieve it?

vjr12 avatar Jul 20 '20 16:07 vjr12