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

[Solved] Drag and Drop but not allow re-order

1 Answer 76 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.
Philip Senechal
Top achievements
Rank 1
Philip Senechal asked on 09 Aug 2011, 08:55 PM
I currently have a page with a TreeView and a Grid. The Grid has a div around it that is identified as a drop target for the TreeView. Dragging and dropping works great, however, I would like to prevent the TreeView from re-ordering nodes if someone accidentally drops the node on the TreeView instead of the Grid.

Is there a way to disable node re-ordering (or dropping on the TreeView) and still allow dropping on my target? Thanks.

1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 10 Aug 2011, 06:49 AM
Hello Philip,

There is a way! To provide the best user experience, attach a handler to the nodeDragging event and set the t-denied status class whenever you want to prevent the drop from happening. In your scenario, it should look like the following:

var treeview = $(".t-treeview")[0];
 
function onNodeDragging(e) {
    if ($.contains(treeview, e.dropTarget)) {
        e.setStatusClass("t-denied");
    }
}


(It is advisable that the treeview is cached outside of the event handler, in order to minimize the DOM lookups)

Kind regards,
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

Tags
TreeView
Asked by
Philip Senechal
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or