Categories | Question details Back To List | ||
Enable/Disable drag/drop on node-by-node basis Enable/Disable drag/drop on node-by-node basis I appreciate we can revert things with the onDrag events, but can we stop the drag in the first place ? Ie. 1st child nodes should not be draggable, but the siblings can be. This links also into node-by-node drop enable/disable. So in theory I could drop my sibling onto a certain enabled-for-drop child node, but not the root node or other sibling nodes. If I try to drop a sibling onto another sibling (which would auto-create a new child/sibling relationship), then the mouse-cursor should be an X or something, and not let me drop there... Does that make sense? So I want to be able to rearrange (drag/drop) the siblings within the child, but not allow the sibling to be dropped onto another sibling. Thanks! Answer posted by Support on Feb 13, 2008 05:00 a) You can block drop operation by onDragIn event ( it occurs when item dragged other potential drop target ) tree.attachEvent("onDragIn",function(sid,tid){ if (some_condition) return false; //block drop return true; //allow drop }); b) There is no event for start of drag, but it can be done with code modification dhtmlxtree.js , line 3676 dhtmlXTreeObject.prototype._createDragNode=function(htmlObject,e){ if (!this.dADTempOff) return null; var obj=htmlObject.parentObject; if (some_rule) return null; << can be added here , obj.id == item ID Answer posted by Max on Feb 13, 2008 05:13 Thank you. Your code modification will do the trick ! -- Maybe I could mention a feature request for you to consider: In the XML, we can add "nodrop" and "nodrag" on a node-by-node basis, if we wish to disable on certain nodes! Answer posted by Support on Feb 13, 2008 05:57 >>In the XML, we can add "nodrop" and "nodrag" on a node-by-node basis, if we wish to disable on certain nodes! We plan to add something similar in next versions, because it is a really common use-case. |