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

Dragging from tree to div: how to obtain X/Y coordinates?

5 Answers 138 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Pablo
Top achievements
Rank 1
Pablo asked on 18 Nov 2014, 12:26 AM
In this AngularJS TreeView (see here) the user can drag a tree node and drop it in a div. I analyzed the drop event with console.log(e) however I cannot see the usual e.clientX/e.clientY or e.offsetX/e.offsetY to determine where in the div the node was dropped. Is it possible to obtain these coordinates?

Thanks
Pablo

5 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 19 Nov 2014, 12:09 PM
Hi,

You need to initialize the drop target as Kendo UI DropTarget and use its drop event. Here is the example:

http://dojo.telerik.com/ONabi

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Pablo
Top achievements
Rank 1
answered on 19 Nov 2014, 07:29 PM
Thanks Kiril. 

Your post works on Chrome and IE, unfortunately it doesn't work on FF (I get "undefined offsetX and  undefined offsetY").

Also, is it possible not to have the "forbidden" icon when the node is dropped, and not have the node return to the tree?

In my example I achieve that with:

if (e.dropTarget.id=="dropHere")
              e.setStatusClass("k-add");

in the drag event, and with 

e.preventDefault();

in the drop event.


Thanks
Pablo

0
Kiril Nikolov
Telerik team
answered on 20 Nov 2014, 12:48 PM
Hi,

Please check the following example and let me know if it helps:

http://dojo.telerik.com/ONabi/3

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Pablo
Top achievements
Rank 1
answered on 21 Nov 2014, 05:41 PM
Thanks Kiril, the drop event was missing, I added it to this dojo. Unfortunately this only works in Chrome; in IE10 and FF33 e.offsetX and e.offsetY return 'undefined'. I couldn't find any other coordinates I could take from the event. Any ideas?


Thanks
Pablo
0
Kiril Nikolov
Telerik team
answered on 25 Nov 2014, 11:39 AM
Hello P,

In IE10 you can use the originalEvent property. Here is an example:

http://dojo.telerik.com/ONabi/6

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
TreeView
Asked by
Pablo
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Pablo
Top achievements
Rank 1
Share this question
or