This is a migrated thread and some comments may be shown as answers.
Client side: How to find out the TARGET node the mouse in over in OnClientNodeDragging?
3 Answers 34 Views
This is a migrated thread and some comments may be shown as answers.
Sebastian
Top achievements
Rank 2
Sebastian asked on 19 Jan 2010, 12:15 PM
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

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 22 Jan 2010, 09:25 AM
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.
0
Sebastian
Top achievements
Rank 2
answered on 22 Jan 2010, 10:22 AM
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.
0
Yana
Telerik team
answered on 22 Jan 2010, 03:52 PM
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.
Asked by
Sebastian
Top achievements
Rank 2
Answers by
Yana
Telerik team
Sebastian
Top achievements
Rank 2
Share this question
or