Results 1 to 2 of 2

Thread: Drag and drop to TreeGrid: allow append between nodes but not into nodes

  1. #1
    Sencha User
    Join Date
    Apr 2010
    Posts
    10

    Question Drag and drop to TreeGrid: allow append between nodes but not into nodes

    I have a TreeGrid with different types of elements. On some of them I want to allow insertion even if they are leaves and on some of them I do not. I've managed to get this working by allowing DropOnLeaf on the DropTarget and checking in the dragMove method of the DNDListener if we are dropping into one of the elements that can receive new childen.

    My problem is that, besides this, I want to allow node reordering without limitations. What happens now is that I can't insert elements between elements that cannot receive new children.

    I guess the problem is my dragMove logic as it forbids drops over elements that do not allow children, but when I try to drop between two elements that do not allow children the pointer is always over one of them.

    In conclusion I'd like to know if it is possible to know in the dragMove event if the mouse is in between two elements or if it is fully over one of them.

  2. #2
    Sencha User
    Join Date
    Apr 2010
    Posts
    10

    Lightbulb Solution

    Just answering myself in case this is useful for anybody else. I was able to solve this problem by getting the Y coordinate of the event and comparing it with the coordinates of the element where the drop was being attempted.

    The coordinates of the element can be otained by doing
    Code:
    Model target = tree.findNode(e.getTarget()).getModel();
    Element ele = tree.getView().getRow(target);
    where e is a DNDEvent object. Then the top and bottom Y coordinates are:
    Code:
    ele.getAbsoluteBottom()
    ele.getAbsoluteTop()
    The Y coordinate of the DNDEvent can be otained with the getClientY() event

    Then I could find if the drop was being done in between the elements with this condition:

    Code:
    if (((e.getClientY() < (ele.getAbsoluteBottom() - 4)) && (e.getClientY() > (ele.getAbsoluteTop() + 4))))

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •