0
votes

I am using jquery-dynatree with context-menu option.

For one of the menu item on context-menu, I need to show the entire sub-tree as a selection. i.e. selected node and all its children, I am able to do that using below code :

node.visit(function(childnode){
    $(childnode.span).addClass("copy");  // <== This works
});

Now I have 2 issues:

1) First issue is I have lazy node option, so whenever I click on menu-item, I need to show entire sub-tree as selected, for that I am using below code

node.visit(function(childnode){
    childnode.expand(true);  // <== This works
    $(childnode.span).addClass("copy"); // <== Does not work
});

but it does not work fully, it only expands the nodes upto level I have initialized and also after expansion it does not add required CSS class "copy" to itself or children nodes.

2) Second issue is , once I have manually expanded all the nodes and selected parent-node so that entire subtree is shown using class "copy" , now whenever I click on any parent lazy node to retrieve those children, the "copy" class is removed from those selected nodes

Looking forward to some tips on solving this.

1

1 Answers

0
votes

I have got the solution now for 1st point, as I was trying to click on parent in collapsed mode, I had to first expand the node itself before expanding its children nodes.

 node.expand(true); // This line was missing, it made the things work
                node.visit(function(childnode){
                    childnode.expand(true);
                    $(childnode.span).addClass("copy");
                });