Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Smith on Sep 29, 2008 12:42
open dhtmlx forum
dhtmlxTree: Is there a way to allow drag and drop only for certain nodes?

Hello,

I'm looking for a way to only allow drag and drop into certain nodes. For example, I have two trees. The user can drag items from the left tree into the right tree. However, I only want the user to be able to drag those items into certain folders.

Is this possible? Thanks.

-Smith
Answer posted by Stanislav on Sep 29, 2008 15:27
You can use onDragIn event ( the next article http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Managed_Drag_and_Drop.html#grid_mandnd describes details of d-n-d of grid, but tree has the same events , so the same solution can be used )

target_tree.attachEvent("onDragIn",function(sid,tid){ //sid - draged element id, tid - drop landing id
       if (some_custom_rules(sid,tid)) //check if d-n-d allowed
             return true; // allow
       else
            return false; //or deny
})