DHTMLTREE : HOW TO RESTRICT DROP ON SELECTED TREE NODES with

hi,

I have written code











Tree and Context menu



















    

























Tree with context menu













Some text







Role 1









Role 2









Role 3





















now I want to restricr that when I drop roles on tree barnches it will allow me to drop on only node whose Id starts with ‘Branch’



Please help



thanks in advance



Regards

Shalini


Hello,


there is make makeDragable that allows to define any action for the dragged element:


tree.makeDragable(“el_id”,function(drop_obj,source_id,target_on,target_before){

});


Please, see the sample dhtmlxTree/samples/drag_n_drop/drag_in_simple.html


But onDragIn should return true in order to enable drag-n-drop









hi



Please find my code attached



now I want to restrict that when I drop any Roles div on tree nodes, then it will allow me to drop role div only on those nodes whose Id starts with ‘Branch’

Please help and suggest

Regards
Shalini


Mycode.zip (67.9 KB)


You can usemakeDragable method. For example:


tree.makeDragable(“Role1”,addItem)



tree.makeDragable(“Role2”,addItem)
tree.makeDragable(“Role3”,addItem)
function addItem(drop_obj,source_id,target_on,target_before){
if(tree.getItemText(target_on) && tree.getItemText(target_on).indexOf(“Branch”)!=-1)
drop_obj.insertNewItem(target_on,source_id,source_id);
};




thanks , its working now…