Dynatree展开选定的节点的父母(Dynatree Expand Parents of Sele

2019-09-19 01:28发布

I have Dynatree running well on my page. I am using an initAjax to get the structure. When I generate my json I include "select": true where appropriate to select check-boxes. Most (all) of the check-boxes are at a depth of three levels down from the root.

I would like to expand the parents of the selected nodes so the user can see the selected check-boxes when the page loads.

I think I need to do something on the onPostInit function with getSelectedNodes, but I can not nail down the code?? I'm not sure if I should be using a each statement to loop through the selected nodes? Any help would be greatly appreciated!

--UPDATE--

I figured it out!!

onPostInit: function(isReloading, isError) {
            var tree = $('#tree').dynatree('getTree');
            var selKeys = $.map(tree.getSelectedNodes(), function(node){
                node.makeVisible();
            });
         }

Answer 1:

略短的响应:

onPostInit: function() {
    $.map(this.getSelectedNodes(), function(node){
        node.makeVisible();
    });
}


文章来源: Dynatree Expand Parents of Selected Nodes