jQuery UI Widgets Forums Navigation Tree How to Determine target of drag/drop

This topic contains 3 replies, has 2 voices, and was last updated by  Hristo 7 years, 6 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • How to Determine target of drag/drop #89209

    AliMajed
    Participant

    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 – F

    and 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

    • This topic was modified 7 years, 6 months ago by  AliMajed.
    • This topic was modified 7 years, 6 months ago by  AliMajed.
    How to Determine target of drag/drop #89230

    Hristo
    Participant

    Hello AliMajed,

    What you would like to achieve. If I understand, you could achieve this change with two methods – removeItem and addTo.
    Please, take a look at this example.
    Hope this helps.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    How to Determine target of drag/drop #89231

    AliMajed
    Participant

    Hello 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

    How to Determine target of drag/drop #89248

    Hristo
    Participant

    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?light

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.