欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

得到指定节点的所有的父节点

程序员文章站 2022-05-30 16:38:45
...

 

function getAllParentNodeIds(treeNode,result){
                var node = treeNode.getParentNode();
                if (node!=undefined) {
                    result+=','+node.id;
                    result=getAllParentNodeIds(node,result);
                }
                return result;
            }

        $(document).ready(function(){
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);

            /*9ef0839d31d04e4c8b3c2bb254e17454 生活日历*/
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var node = treeObj.getNodeByParam("id", "9ef0839d31d04e4c8b3c2bb254e17454", null);
            var res = getAllParentNodeIds(node,"9ef0839d31d04e4c8b3c2bb254e17454");
            alert(res);
        });


转载于:https://my.oschina.net/u/2441574/blog/495988