icon for drag/drop area not allowed?

8 posts, 1 answers
  1. kyle
    kyle avatar
    22 posts
    Member since:
    Feb 2008

    Posted 12 Feb 2009 Link to this post

    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?

  2. Yana
    Admin
    Yana avatar
    4795 posts

    Posted 16 Feb 2009 Link to this post

    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.
  3. kyle
    kyle avatar
    22 posts
    Member since:
    Feb 2008

    Posted 16 Feb 2009 Link to this post

    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.
  4. Yana
    Admin
    Yana avatar
    4795 posts

    Posted 17 Feb 2009 Link to this post

    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.
  5. kyle
    kyle avatar
    22 posts
    Member since:
    Feb 2008

    Posted 17 Feb 2009 Link to this post

    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.
  6. Yana
    Admin
    Yana avatar
    4795 posts

    Posted 18 Feb 2009 Link to this post

    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.
  7. kyle
    kyle avatar
    22 posts
    Member since:
    Feb 2008

    Posted 18 Feb 2009 Link to this post

    So i take it the custom attributes are out of the question also?
  8. Answer
    Yana
    Admin
    Yana avatar
    4795 posts

    Posted 18 Feb 2009 Link to this post

    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.
Back to Top