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

icon for drag/drop area not allowed?

7 Answers 228 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
kyle
Top achievements
Rank 1
kyle asked on 12 Feb 2009, 06:25 PM
I am dragging and droping nodes between two telerik treeviews.  I notice when I hover over an item in the dropping treeview it highlights the node where i want to drop.  Is there a way to indicate to the user when they move the dragged node over top of the white area to show a circle with a slash through it like Visual studio does when droping controls on to the design for an area that you are not allowed to drop an item onto?

7 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 16 Feb 2009, 09:53 AM
Hello Kyle,

You should subscribe to OnNodeDragging event of RadTreeView and check args.get_htmlElement() like this:

function onNodeDragging(sender, args)  
{  
    var target = args.get_htmlElement();      
      
    if(!target) return;  
    if(target.className != "rtTop" &&  
       target.className != "rtMid" &&  
       target.className != "rtBot" &&  
       target.className != "rtIn" &&  
       target.className != "rtPlus" &&  
       target.className != "rtMinus")  
       target.style.cursor = "not-allowed";  

if the node is not dragged over a node, the cursor is set to "not-allowed".

Greetings,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
kyle
Top achievements
Rank 1
answered on 16 Feb 2009, 12:07 PM
Yana,

This is a good start, but I think I might have not been clear on what I wanted. I want to be able to change the cursor or a graphic around the cursor so while I am dragging (I havent released the mouse button yet) the icon would show the user some visual indication that they can not drop the item they are dragging over (white area of a treeview) and switch to normal visual indicators when they are actually over top of a node.  I hope this makes sense.
0
Yana
Telerik team
answered on 17 Feb 2009, 09:52 AM
Hello Kyle,

Did you try the code form my previous post in OnNodeDragging event  hander (it's fired while you're dragging before releasing mouse button) ? I think it's exactly what you need - it changes cursor when you over a different from a node element, you can only remove "rtPlus" and "rtMinus" from the condition:

function onNodeDragging(sender, args)  
{  
    var target = args.get_htmlElement();      
      
    if(!target) return;  
    if(target.className != "rtTop" &&  
       target.className != "rtMid" &&  
       target.className != "rtBot" &&  
       target.className != "rtIn")  
       target.style.cursor = "not-allowed";  

All the best,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
kyle
Top achievements
Rank 1
answered on 18 Feb 2009, 12:29 AM
I got this to work! I mis-understoof that this was a javascript event and not a server side event.

Anyways along the same lines i would like to know if there is a way to get the category of an item the mouse is over.
I can use this: args.get_node().get_category() to get the category of the node we are dragging but what about the category of
the item we are over? So then we can set the cursor style to now allowed.
0
Yana
Telerik team
answered on 18 Feb 2009, 09:57 AM
Hello Kyle,

I am sorry for the misunderstanding with the client-side event.

Unfortunately you cannot get the category of the node which  you're dragging over as you have only the html element in OnClientNodeDragging handler.  

Best regards,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
kyle
Top achievements
Rank 1
answered on 18 Feb 2009, 11:44 AM
So i take it the custom attributes are out of the question also?
0
Accepted
Yana
Telerik team
answered on 18 Feb 2009, 12:21 PM
Hello Kyle,

I am afraid that you cannot get custom attributes either. The reason is that they are not rendered on the page.

Regards,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
kyle
Top achievements
Rank 1
Answers by
Yana
Telerik team
kyle
Top achievements
Rank 1
Share this question
or