jQuery UI Widgets Forums Navigation Tree how to set max depth for a tree ?

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 10 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • how to set max depth for a tree ? #59010

    qct222
    Participant

    Hi,

    I’m using jqxTree , I want to set the tree max depth to 1. so that I can drag the leaves.

    the product functionality is : users can change the priority.

    so I want to use jqxTree to reach it.

    the product is using jqx widgets. so can’t change to other js trees.

    so any one could help me ?

    I wrote a examle,but there is bugs .

    $(“#priorityTree”).on(‘dragEnd’, function (event) {
    var items = $(‘#priorityTree’).jqxTree(‘getItems’);
    for(var i=0;i<items.length;i++) {
    if(items[i].parentElement != null) {
    var itemBak = items[i];//item to be removed
    var parentItem = $(‘#priorityTree’).find(“#” + items[i].parentId)[0];
    $(‘#priorityTree’).jqxTree(‘removeItem’, items[i]);
    $(‘#priorityTree’).jqxTree(‘addAfter’, {label : itemBak.label}, parentItem);
    }
    }
    });

    at first there are 4 leaves.when I drag one on to another,they become father and child,I don’t want father and child,only want they all at one level. so when drag one on to another,I remove the child and then and the child after father.

    the bug is : the tree is in a popup window, bug I can drag leaves out of the tree div even the popup window.

    who can help me ??? thanks

    how to set max depth for a tree ? #59212

    Dimitar
    Participant

    Hello qct222,

    You can cancel dropping items inside their siblings with the following code:

    $('#jqxTree').jqxTree({ source: source, width: '100%', height: '100%', allowDrag: true, allowDrop: true,
        dragEnd: function (item, dropItem, args, dropPosition, tree) {
            if (item.level == dropItem.level && dropPosition == "inside") {
                return false;
            }
        }
    });

    As for your other question – drag/drop of tree items is not limited to the tree to allow dragging/dropping to other objects, as shown in the following demo: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxtree/dragdrop.htm?arctic.

    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.