Client side: How to find out the TARGET node the mouse in over in OnClientNodeDragging?

4 posts, 0 answers
  1. Sebastian
    Sebastian avatar
    13 posts
    Member since:
    Feb 2009

    Posted 19 Jan 2010 Link to this post

    Hi,

    I need to retrieve some information about a target node while dragging. This is needed to give the user an optical feedback if he is allowed to drop the node he currently is dragging onto the node he currently is over.

    For that I need to retrieve the supposed target node and compare several attributes against the source node to determine if the operation is valid or not.

    Waiting until the user actually dropped the node and cancelling the OnClientNodeDropping event is NOT an option. The user must be able to see if the desired operation is valid or not BEFORE dropping.

    So how can I retrieve the supposed target node in the OnClientNodeDragging event?

    Thanks,

       Sebastian
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 22 Jan 2010 Link to this post

    Hello Sebastian,

    In OnClientNodeDragging event handler you can retrieve only the html element that the mouse is over at the moment the event fires.  You can use this information to find the client-side object of the node like this:

    function ClientNodeDragging(sender, eventArgs) {
         var node = eventArgs.get_node();
         var htmlEl = eventArgs.get_htmlElement();
         if (htmlEl.className.indexOf("rtIn") > -1 && htmlEl != node.get_textElement()){
             var targetNode = sender.findNodeByText(htmlEl.innerText);
              
         }        
     }

    Best wishes,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sebastian
    Sebastian avatar
    13 posts
    Member since:
    Feb 2009

    Posted 22 Jan 2010 Link to this post

    I tried to help myself in the mean time with this code:
    function OnClientNodeDragging(sender, eventArgs) { 
      var targetNode = sender._extractNodeFromDomElement(eventArgs.get_htmlElement()); 
      if (targetNode) { 
        // do some validation... 
      } 
    That worked well so long.
    Is there something wrong with that?

    Edit update: Okay. Very obviously your code does not work. It does not return the valid node the currently dragged node is over. My code does work, though.
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 22 Jan 2010 Link to this post

    Hello Sebastian,

    I've tested the code and it worked at our side, but I also think that your approach is better.


    Kind regards,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top