jQuery UI Widgets › Forums › Navigation › Tree › How to Determine target of drag/drop
Tagged: angular tree, angular2 tree, bootstrap tree, drag, drop, javascript tree, jquery tree, jqwidgets tree, jqxtree, typescript tree
This topic contains 3 replies, has 2 voices, and was last updated by Hristo 7 years, 10 months ago.
-
Author
-
Inside the ‘dragEnd’ event, how can I determine where the object was dragged in terms of parent/child?
I have a table named “Group” that has 3 fields : 1) ID – 2) ParentID – 3) Title. when I drag an Item to another, I want to change the Item parent to new one. Like if I have these data inside the table:ID – ParentID – Title
1 – 0 – A
2 – 0 – B
3 – 1 – C
4 – 1 – D
5 – 2 – E
6 – 2 – Fand I drag “F” to “A”, I want to change the Parent of “F” from 2 to 1, how can I do that ?
I can get The “F” ID by:
var item = $(#jxqTree).jqxTree(‘getSelectedItem’);
var itemID = $(item).attr(‘id’);but how can I get the “A” (parent node) ID ?
Thanks in Advance
Hello AliMajed,
What you would like to achieve. If I understand, you could achieve this change with two methods –
removeItem
andaddTo
.
Please, take a look at this example.
Hope this helps.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHello Hristo
Thanks for your comment, but your solution is Not what I am looking for. I need to get 2 parameters :
1) the ID of the element that I want to drag it based on the table in my data base.
2) the ID of the element that is destination of drag/drop action based on the table in my data base.I can get the firs parameter by code:
var item = $(#jxqTree).jqxTree(‘getSelectedItem’); var itemID = $(item).attr(‘id’);
so the firs parameter is “itemID”. but I do not know how to get the second parameter.
Thanks in Advance
Hello AliMajed,
You could achieve this on the analogically way as in the shared example.
Set id for the items that want to make changes (as an element is removed).
I am not sure to understand you on the right way.
By default items do not have an id if you want could set to them.
Also, please, take a look at this example, there is one approach to set id:
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxtree/treebindingtojson.htm?lightBest Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.