Login Register

how to reorder via DnD tree items

On lists it is easy to reorder items via DnD, on a Tree it is easy (or at least documented in form of a test) to drop items on other items so they become child items. But what if I want just to reorder the childs of a node via DnD ? Is that possible somehow just with markup or any hints what I need to overwrite via Javascript ?

regards
--
Roberto Saccon
http://rsaccon.com

At the moment, such

At the moment, such functionality is missing from dijit.Tree.

You'd need to drag child nodes back to the same parent, in order to trigger the DnD logic to move the "dragged" child to the bottom of the list.

I do hope this gets added to Tree DnD soon, as I'm also affected by this.

You can do this with dijit.Tree

You can re-order child nodes within a Tree.
Using these resources:
http://dojotoolkit.org/forum/dijit-dijit-0-9/dijit-support/dnd-digit-tre...
http://dojotoolkit.org/book/book-dojo/part-2-dijit-dojo-widget-library/a...

Main points are:
Set tree's 'dndController' to "dijit._tree.dndSource"
implement the following Tree methods:
checkAcceptance, checkItemAcceptance

I also implement the Tree model's 'onAddToRoot' and 'onLeaveRoot' methods so that I can drag a child node onto the root node.
Currently every node is created as a dndSource so if there a nodes that you don't want to be draggable, you will have to allow them to be dragged but not dropped.

give example

Andy: I would love to see a working example of this.

The two sources you referenced are rife with errors (see comments below each). Might you be able to paste a single, working block of code so I could see how this goes? Thanks a million :-).