Dynatree Expand Parents of Selected Nodes

2019-05-07 13:58发布

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();
            });
         }

1条回答
爷的心禁止访问
2楼-- · 2019-05-07 14:36

Slightly shorter response:

onPostInit: function() {
    $.map(this.getSelectedNodes(), function(node){
        node.makeVisible();
    });
}
查看更多
登录 后发表回答