Question

I'm currently working on a django project and i'm using dynatree to build treeview. I have two trees, first tree has items that user can select and the selected items will be moved to second tree. Is there a way that I can do so in dynatree?And there's an option for user to "unselect" the item so the selected item will move back to the first tree. So when user unselect the item, how can i move the item back to its original parent node? Thanks in advance..

Was it helpful?

Solution

I've solved my problem using the copy/paste concept of context menu. And for the second problem, I used global variable to store the original parent node so when user unselect the item, it will move back to its original parent.

OTHER TIPS

I have a dynamTree on a DIV dvAllLetterTemplates (which contains a master List) and a DIV dvUserLetterTemplates to which items are to be copied.


//Select the Parent Node of the Destination Tree
var catNode = $("#dvUserLetterTemplates").dynatree("getTree").selectKey(catKey, false);
if (catNode != null) {
//Select the source node from the Source Tree
    var tmplNode = $("#dvAllLetterTemplates").dynatree("getTree").selectKey(arrKeys[i], false);
    if (tmplNode != null) {
        //Make a copy of the source node
        var ndCopy = tmplNode.toDict(false, null);
        //Add it to the parent node
        catNode.addChild(ndCopy);
        //Remove the source node from the source tree (to prevent duplicate copies
        tmplNode.remove();
        //Refresh both trees
        $("#dvUserLetterTemplates").dynatree("getTree").redraw();
        $("#dvAllLetterTemplates").dynatree("getTree").redraw();
     }
}

There is a difference between 'selected' and 'active'. Selection is typically done using checkboxes, while only one node can be activated (typically by a mouse click). A 2nd click on an active node will not fire an 'onActivate' event, but you can implement the 'onClick' handler to catch this and call node.deactivate()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top