JQuery treeview disable drag/drop inside but allow drag/drop to listbox

1 Answer 245 Views
Drag and Drop ListBox TreeView
David
Top achievements
Rank 1
David asked on 23 Jul 2021, 03:49 PM | edited on 23 Jul 2021, 03:54 PM

I am trying to disable the drag/drop within the treeview (as in the user wont be able to move any items anywhere inside the treeview). However I am not coming up with a solution for this issue.

I still want the user to be able to drag/drop an item that's inside the treeview over to my listview box as well as drag/drop it back to the treeview box.

So is it possible to disable the drag/drop feature inside the treeview when keeping the drag/drop from there to my listbox?

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 28 Jul 2021, 10:28 AM

Hello David,

I would suggest you in the drop event handler of the TreeView to check the target destination and prevent the default behavior if needed. Below is an example:

function onDrop(e){          
       
        if($(e.destinationNode).attr('role') == "treeitem"){          
          
          e.preventDefault()
          
        } 
         .....
}

Here is a Dojo example where this is demonstrated.

Let me know in case you have additional questions on the matter..

Regards,
Neli
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Drag and Drop ListBox TreeView
Asked by
David
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or