Articles in this section

How to show assistants for the parent node in organization layout?

This article explains how to show assistants for the parent node in an organization layout. The diagram component provides the feature to create an organization chart in JavaScript. A child item having a different relationship with the parent node is known as an assistant. Such a child item can be set as an assistant of its parent by adding it to the assistant property in the options argument. The following code sample explains how to set assistants to a parent node in an organization chart.

let data: object[] = [{Id: 1, Role: "General Manager"},
    {Id: 2, Role: "Assistant Manager",Team: 1},
    {Id: 3, Role: "Human Resource Manager",Team: 1},
    {Id: 4,Role: "Design Manager",Team: 1},
    {Id: 5,Role: "Operation Manager",Team: 1},
    {Id: 6,Role: "Marketing Manager",Team: 1}
];
let diagram: Diagram = new Diagram({
    width: '100%',
    height: '530px',
    snapSettings: {
        constraints: 0
    },
   //Uses layout to auto-arrange nodes on the diagram page
    layout: {
        //Sets layout type
        type: 'OrganizationalChart',
        // define the getLayoutInfo
        getLayoutInfo: (node: Node, options: TreeInfo) => {
            if (node.data['Role'] === 'General Manager') {
        //selects the Assistant Manager and Human Resource Managerchild as assistants
                options.assistants.push(options.children[0], options.children[1]);
       //the selected assistants are removed from children
                options.children.splice(0, 2);
            }
            if (!options.hasSubTree) {
                options.type = 'Center';
                options.orientation = 'Horizontal';
            }
        }
    },
    //Initializes the node template.
    dataSourceSettings: {
        id: 'Id',
        parentId: 'Team',
        dataManager: items
    },
});

 

In the above code sample, the General Manager is the parent node. The Assistant Manager and the Human Resource Manager are pushed (added) as assistants to the parent node. The nodes added as assistants are spliced (removed) from the parent node’s children array. The assistants are added to a parent node in this manner. Numerous child nodes can be added as assistants to a parent node in an organization chart. The dataSourceSettings is used to set the parent ID for the nodes.


Refer to the working sample for additional details and implementation: Sample


Conclusion

We hope you enjoyed learning about how to show assistants for the parent node in the organization layout.

You can refer to our JavaScript Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.  You can also explore our JavaScript Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsBoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied