Home - Forums-.NET - FlyTreeView (ASP.NET) - Reorder Tree with Drag and Drop

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Reorder Tree with Drag and Drop
Link Posted: 17-Aug-2007 05:12
I have a tree (built from SQL) where I want to use the drag and drop functionality to 're-order' the nodes.
E.G

- Parent
--- Node 1
--- Node 2
--- Node 3

- Parent
--- Node 3
--- Node 1
--- Node 2

I'd then scan through the tree and use an SP to change the order column in SQL. I'd like to be able to reorder an entire parent and children at the same time.
I have it working using two tree (a 'source' and 'target') but I don't like the functionality much.
Can I do this? I'm a java simpleton so if it's all client side please give me details.
Thanks
Link Posted: 17-Aug-2007 08:14
So do you just need to D&D parent nodes.
Probably you need to define FlyTreeView.RootDragDropAcceptNames to make treeview's root accepting drops.
Link Posted: 30-Oct-2008 07:27
I have a similar problem (if its not the same)

I have the following:

Parent 1
---- Child 1
---- Child 2
---- Child 3
---- Child 4

What I want to be able to do is drag and drop Child 4 between Child 1 and 2 so that it re-orders the nodes.

Is this possible?
Link Posted: 30-Oct-2008 07:39
This is hardly possible.
FlyTreeView does not provide nodes reordering itself.
Every time you drop node, it is appended. So the only way to make Child 4 be between Child 1 and Child 2 is to drop 2 and 3 to Parent1. I think this is not what your user would like to do.

So the basic answer is - No.
Anyway there always can be another solution (sorting nodes at postback, or other).
Let me know if I can help you.
Link Posted: 30-Oct-2008 23:12
Is there a way to detect if the dragged item is dropped between nodes?

At the moment I have a solution of sorts, but it only works as I have set a specific type of node not to allow children (by using client side code)

If I can detect whether the dragged item is dropped between nodes, this would make things much easier
Link Posted: 31-Oct-2008 00:43
There's nothing that can help with this (at least for the current version).
FlyTreeView does not contain client event handlers that would allow to handle when dragged node is between nodes.
Link Posted: 31-Oct-2008 00:48
It would be great to see this added as a feature, as your competitor's products do have this feature.

However, for the mean time, I'm using the shift key as a modifier.



                    function ftvMenu_OnDrop(target, event) {
                        
                        var parentNode;
                        var parentNode;
                        var targetIndex;
                        if (target instanceof CFlyTreeView) {
                            // target=rootdropzone
                            parentNode = target;
                            targetIndex = target.getNodes().length;
                        }
                        else {
                            var parentNode = target.getParent();
                            if (parentNode == null) parentNode = target.getTreeview(); //target=rootobject
                            targetIndex = target.getIndex();
                        }

                        var node = flytreeview_dragObject.value;

                        // If our source and target are the same type, insert at that level
                        // unless the shift key is held down
                        if (
                            node.getNodeTypeID() == target.getNodeTypeID()
                            && event.shiftKey == false
                            ) {
                            node.remove(); // remove first from previous location
                            parentNode.insertNode(node, targetIndex);

                            return false; // to skip default action
                        }
                    }



Then set your OnDropJavaScript event to "ftvMenu_OnDrop"
Link Posted: 31-Oct-2008 00:55
Thanks for your feature suggestion.
We are always glad to get customer feedback, this allows us to improve our vision on what actual features are mostly required.