Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Nick Armitage on Oct 22, 2007 13:08
open dhtmlx forum
Can I make a tree dropable but not dragable?

In order for drag and drop to work on a tree, I use myTree.enableDragAndDrop(true)
I use this so I can drag a row from a grid and drop it on the tree to move things around and it works fine.

However, this makes the tree draggable as well which means I can drag nodes and change the tree structure which in this instance, I do not want to happen.

I know I can prevent the drop from occurring on the tree by implementing a custom drag handler and checking that the source and target objects are not the same.
But, I was wondering if it was possible to prevent the tree from being dragable in the first instance - whilst still keeping it dropable?

In other words, it would be really neat if the following were implented:
  myTree.enableDragAndDrop - to enable both drag AND drop
  myTree.enableDrag - to enable the tree to be draggable (but NOT droppable)
  myTree.enableDrop - to enable the tree to be droppable (but NOT dragable)

Answer posted on Oct 23, 2007 10:11
While API doesn't allow to enable drag and drop as separate operation, it pretty easy to disable drag in tree ( drop will be untouched )
Next line do the job

    myTree._createDragNode=function(){ return false; }

such solution will work for dhtmlxGrid as well