This is a migrated thread and some comments may be shown as answers.

avoid dropping inside tree view

3 Answers 69 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marco Teodoro
Top achievements
Rank 1
Marco Teodoro asked on 09 Jun 2010, 03:11 PM
how can i make tree view undroppable.

i want ti drag from tree view and drop on a specific div, no inside tree view.

best regards

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 10 Jun 2010, 08:24 AM
Hello Marco Teodoro,

  1. attach an event handler to the nodeDragging event and deny the dragging of nodes over the treeview:
    function onNodeDragging(e) {
        if ($(e.dropTarget).closest('.t-treeview').length > 0)
            e.setStatusClass('t-denied');
    }
  2. prevent the default action of the nodeDrop event and handle the drops onto the div elements, like this:
    function onNodeDrop(e) {
        e.preventDefault();
     
        var dropContainer = $(e.dropTarget).closest('.drop-container');
        var treeview = $('#TreeView').data('tTreeView');
                 
        if (dropContainer.length > 0) {
            $('<div><strong>' + treeview.getItemText(e.item) + '</strong></div>')
                .hide().appendTo(dropContainer).slideDown('fast');
        }
    }

I'm attaching the modified Drag&Drop demo that illustrates the above approach.

Best wishes,
Alex Gyoshev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jronny
Top achievements
Rank 1
answered on 27 Aug 2010, 04:03 AM
Will this functionality be added to the next release?
0
Jon
Top achievements
Rank 1
answered on 23 Nov 2010, 10:10 PM
Should the following show the red circle with a line through it when dragging over the treeview control?
function onNodeDragging(e) {
    if ($(e.dropTarget).closest('.t-treeview').length > 0)
        e.setStatusClass('t-denied');
}
I'm using the Extensions for ASP.NET MVC Q3 2010 Live Examples (Win7, IE8 and FF3.6) with your attached drag-n-drop sample and I get the plus and insert inbetween icons when dragging over the treeview control.

It seems that the onNodeDragging function never gets called. If I insert an alert("hi"); before the if statement, I don't see the popup.

It does prevent dropping the node anywhere on the tree.

Thanks.
Tags
TreeView
Asked by
Marco Teodoro
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Jronny
Top achievements
Rank 1
Jon
Top achievements
Rank 1
Share this question
or