Dynatree Expand Parents of Selected Nodes

徘徊边缘 提交于 2019-12-22 08:23:55

问题


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:


Slightly shorter response:

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


来源:https://stackoverflow.com/questions/11310862/dynatree-expand-parents-of-selected-nodes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!