2

我正在使用GetOrgChart创建组织结构图。

一切运行顺利,但它不允许您折叠其他节点并保持当前节点打开。

请查看JSFiddle示例,我从那里获取演示。

他们的文档expandOrCollapse中列出了一种方法,但没有详细说明它是如何工作的。

我只是想知道这在 GetOrgChart 组件中是否可行。

提前致谢。

4

1 回答 1

1

您可以使用扩展方法。

这是方法expand(node, callback)的签名

  • node - 是节点对象,如果您知道要扩展节点对象的节点的 id 是 orgchart.nodes[“expandToThisId”]
  • callback – 将组织图展开到指定节点的动画,动画完成时调用回调方法

和例子:

        var orgchart = new getOrgChart(document.getElementById("people"),{		
        		expandToLevel: 2,
            scale: 0.5,
            dataSource: [
                { id: 1, parentId: null, Name: "1"},
                { id: 2, parentId: 1, Name: "2"},
                { id: 3, parentId: 1, Name: "3"},
                { id: 4, parentId: 2, Name: "4"},
                { id: 5, parentId: 2, Name: "5"},
                { id: 6, parentId: 3, Name: "6"},
                { id: 7, parentId: 3, Name: "7"},
                { id: 8, parentId: 5, Name: "8"},
                { id: 9, parentId: 5, Name: "9"}]
        });
        
        orgchart.expand(orgchart.nodes["5"]);
        
html, body {margin: 0px; padding: 0px;height: 100%; overflow: hidden; }
#people {width: 100%;height: 100%; }
<link href="http://www.getorgchart.com/GetOrgChart/getorgchart/getorgchart.css" rel="stylesheet"/>
<script src="http://www.getorgchart.com/GetOrgChart/getorgchart/getorgchart.js"></script>
<div id="people"></div>

于 2017-01-13T21:18:56.127 回答