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

How to disable drag-and-drop functionality for specific nodes?

6 Answers 237 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.
Jronny
Top achievements
Rank 1
Jronny asked on 27 Aug 2010, 03:55 AM
I have a treeview whose nodes are draggable to a specific target. But the nodes  should not be reorganized, thus they need to be prevented from dragging-and-dropping on the treeview. So I used
    function onTreeViewToolBoxNodeDragging(e) {
        if ($(e.dropTarget).closest('.t-treeview').length > 0)
            e.setStatusClass('t-denied');
    }
But the thing is, the root nodes are also draggable to the target specified. How can we prevent this from happening? Thanks.

6 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 27 Aug 2010, 04:29 PM
Hi Jronny,

Theoretically, you can easily prevent the dragging of specific nodes using the NodeDragStart event, like this:
function nodeDragStart(e) {
    if ($(e.item.parentNode).is('.t-treeview > .t-group'))
        e.preventDefault();
}


We found a bug with the drag&drop API, though, which prevented the above solution to work. The bug is fixed in the attached version of telerik.draganddrop.js.

Sincerely yours,
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
Paul
Top achievements
Rank 1
answered on 29 Sep 2010, 04:08 AM
I am getting an error in the telerik.treeview.js file when I try to call the "e.preventDefault()" method.

The error is that the "this.$dropClue" object is null.  It blows up on line 379 of the telerik.treeview.js file here is the section:
if (status) {
    this.$dropClue.css('visibility', 'hidden');
    return status;
}

Any tips on how to resolve this issue would be greatly appreciated.  My goal is to disable dragging and dropping of specific nodes like this post is so I thought this might be the best place to post my question.

Thanks,
Paul
0
Alex Gyoshev
Telerik team
answered on 30 Sep 2010, 02:21 PM
Hello Paul,

Can you please post a more detailed example of what you are doing? I have attached a sample solution that illustrates such a scenario -- child nodes are not allowed to be dragged, only parent ones. What is the difference in your scenario? Please note that the solution uses the updated telerik.draganddrop.js file.

All the best,
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
Paul
Top achievements
Rank 1
answered on 30 Sep 2010, 02:30 PM
I will try that but I have the non-min-fied version of your telerik.draganddrop.js file so I guess I'll have to replace that with the telerik.draganddrop.min.js file and delete the non-min-fied version.

I'll let you know if that doesn't work...

Thanks,
Paul
0
Paul
Top achievements
Rank 1
answered on 30 Sep 2010, 03:45 PM
This fixed the issue but is there anyway I could get a non-min version of the javascript file?  

Or tell me what to change in my telerik.draganddrop.js file?

Thanks,
Paul
0
Alex Gyoshev
Telerik team
answered on 30 Sep 2010, 04:22 PM
Hi Paul,

You can find the original version attached to this post. It is a rather humiliating change...

// OLD:
if (this.onDragStart(e, this.$draggedElement)) {
    // drag cancelled
}

// NEW:
if (this.onDragStart(e, this.$draggedElement))
    return; // drag cancelled


All the best,
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
Jronny
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Paul
Top achievements
Rank 1
Share this question
or