Categories | Question details Back To List | ||
Drag and Drop - Prevent items been dragged Hello I have two trees one contains 'source' data, that I want added to the 'main' tree. The source tree looks something like the following (with more groups - groups are folders) Group A - Item A - Item B Group B - Item C - Item D - Item E The main tree looks like, again the groups are folders. Group 1 - Group 1-1 - Group 1-1-1 - Item A - Group 1-1-2 - Item E - Group 1-2 - Group 1-2-1 - Item D Group 2 - Group 2-1 - Group 2-1-1 - Item A - Item B So what happens is the user drags items from the source tree to the required location in the main tree. Is there any wayto prevent the user from been able to drag the Group (folders) from the source tree to the main tree? and secondly prevent the user from dropping the items anywhere but in the third level of the tree - in the above example. the user should only be able to drop items in the Group 1-1-1, Group 1-1-2, Group 1-2-1 and Group 2-1-1 Thanks David Answer posted by Support on Jan 07, 2009 14:58 dhtmlxTree provides next two events onBeforeDrag onDragIn first occurs when item drag started second occurs when item draged other possible target returning false from event handler will block related operation so you can use such events to add any kind of custom logic. tree.attachEvent("onBeforeDrag",function(sid){ if (tree.getLevel(sid)==1) return false; //block drag of items on first level return true; }); tree.attachEvent("onDragIn",function(sid,tid){ if (tree.getLevel(tid)==3) return true; //allow drop of items on third level return false; }); |