Disabling move node
Hi I would like to ask if I can if I can disable the moving node functionality for a tree. Also for button how can I add one, as the api does not state clearly how to do so.
Hi,
I'm sure fritz-c can elaborate here, but as far as I know you would need to create your own noderenderer to disable the moving functionality. Check out the nodeContentRenderer option.
As for adding buttons, check out the generateNodeProps option and how this is configured in the included example (src/examples/basicExample/app.js)
Thank you @larsts. As larsts said, the example code is a good place to look for the button adding example.
As for disabling moving, I don't have an official way to do it, but the hack explained here might do what you want for now: https://github.com/fritz-c/react-sortable-tree/issues/14#issuecomment-259893522
By the way I have written a typescript definition for your library, so should I make a pull request for you then? Also @fritz-c do you mind let me write the disabling moving for you, perhaps I could clone your repository and then write up a new prop of enable/disable the handle bar.
Also for the length of individual tree node if the text is too long would it wrap? I have tested but I find that it is not able to do so.
I've not used typescript before, so I'm not exactly sure how it works, but if it will benefit other users of the library I'll merge it in.
As for the move disabling, I would be interested in adding a new prop for it. A moveDisabled prop that disables the rendering of the handle (and adds an extra rowContentsMoveDisabled class to replace the missing border on the left side of the node) is basically what I had in mind.
Text wrapping is not possible right now, at least not in the automatic, browser-handled sense. If you made the rowHeight prop tall enough, and added <br /> or some sort of pre style to your text, you could pull it off, but automatic resizing due to height is disabled in favor of using react-virtualized. If you search "react-virtualized" in the issues you can find a few discussions on this matter.
So now for the typescript definition should I make a pull request then?
Sure, that would be great!
Thanks Chris. So I assume that I would firstly fork your project and then add the relevant typescript definitions to a new folder and then compare to your master branch making a pull request, is that right?
I'm not sure how typescript definitions work, so I can't comment on the folder part of it, but the rest of that regarding the pull request is correct.
Hi,
is the moveDisabled props is added in the latest release?
This functionality is now available with the canDrag API in version 0.1.14.
Is there a way to disable the specific nodes only rather than disabling the drag on entire tree
Is there a way to disable the specific nodes only rather than disabling the drag on entire tree
My case was only disabled on the root node, and I used it as below
<SortableTree
{...props}
canDrag={({treeIndex) => treeIndex>0}
/>