Search code examples
orgchartgetorgchart

getOrgChart - Multiple root elements


I am using getOrgChart and would like to know if it is possible to have multiple root elements. For example, I have two managers that have people below them. Instead of listing their common manager, I would like to display the two managers and their staff independently.


Solution

  • Yes it is possible, set the parentId to null

    Run the code snippet bellow

           var orgchart = new getOrgChart(document.getElementById("people"),{			
                enableEdit: false,
                dataSource: [
              { id: 1, parentId: null, Name: "Ivan"},
    					{ id: 2, parentId: 1, Name: "Ava Field"},
    	        { id: 3, parentId: 1, Name: "Evie Johnson"},
    	        { id: 4, parentId: null, Name: "Amber McKenzie"},          
    	        { id: 5, parentId: 4, Name: "Dragan"},
    	        { id: 6, parentId: 4, Name: "Petkan"}
    				]
            });
    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>