jQWidgets Forums

jQuery UI Widgets Forums Navigation Tree Cancel drop depending on resulting level

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 12 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • andreas
    Member

    Hi,

    I’m trying to cancel o approve a drop action based on the resulting level of the node I’m dragging.
    Say for example I have a node in the first level (1), I want to allow dragging but only if it stays in that level, I want to disallow dragging this item so it ends up being a child of another node in the first level for example:

    root (a)
    – first (b)
    — first child of first (c)
    – second (d)
    — first child of second (e)
    — second child of second (f)

    I would allow dragging (b) after (d), but nos as a child of (d)
    I would allow dragging (c) between (e) and (f) but not as a child of (a)

    Makes sense?

    So how would I go about accomplishing this?
    Using the dragEnd property I get the dragItem and dropItem, but sometimes the dropItem doesn’t correspond to the level the dragItem will end up with.
    Before I go into much trouble or maybe trying another widget (I really like this one) I’d like to know how I’d go about this?


    Dimitar
    Participant

    Hello andreas,

    Here is how to achieve this:

                $('#treeA').jqxTree({ allowDrag: true, allowDrop: true, height: '300px', width: '220px', theme: theme, dragEnd: function (dragItem, dropItem, args, dropPosition, tree) {
    if ((dragItem.level != dropItem.level) || dropPosition == "inside") {
    return false;
    };
    }
    });

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.