We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Loop through Swimlane Children nodes in Javascript

Thread ID:





132895 Sep 27,2017 03:37 PM UTC Sep 28,2017 12:32 PM UTC ASP.NET MVC 1
Tags: Diagram
Asked On September 27, 2017 03:37 PM UTC

I have created a diagram with swimlanes and nodes inside that which has connectors as well. Please find the attached screenshot. I am trying to loop through the entire diagram and identify each node and set the fillColor as white. It works correctly for all nodes outside the swimlane but couldnt find the nodes inside the swimlane. I tried using isSwimlane true and getting the children nodes but didnt work. I pasted the javascript below. Can you advise?
var diagram = $("#Diagram1").ejDiagram("instance");
//var jsonData = JSON.parse(data);
//load the JSON data to diagram
for (inodes = 0; inodes < diagram.model.nodes.length; inodes++) {
var allnode = diagram.model.nodes[inodes];
diagram.updateNode(allnode.name, { fillColor: "white" });
if (diagram.model.nodes[inodes].isSwimlane == true) {
for (i = 0; i < diagram.model.nodes[inodes].children.length; i++)
var child = diagram.getNode(diagram.model.nodes[inodes].children[i]);
diagram.updateNode(child.name, { fillColor: "white" });

Attachment: SwimlaneDiagram_284d1ac9.zip

Shyam G [Syncfusion]
Replied On September 28, 2017 12:32 PM UTC

Hi Karthick, 
The swimlane structure created at the initial rendering will be converted into the group node internally with its children as a string and added it into the model nodes collection. So please use getNode method to get the swimlane structure and then iterate the lanes to get the children in lane. Please refer to the code example below in which we have shown how to get the nodes from the lane. Also please refer to the playground link for more details.  
Code example: 
function getLaneChildren() { 
            var diagram = $("#diagram").ejDiagram("instance"); 
            for (var i = 0; i < diagram.model.nodes.length; i++) { 
                var node = diagram.model.nodes[i]; 
                if (node.isSwimlane) { 
                    //to get the swimlane structure 
                    var swimlane = diagram.getNode(node); 
                    //iterate the lanes 
                    for (var j = 0; j < swimlane.lanes.length; j++) { 
                        var lane = swimlane.lanes[j]; 
                        //iterate the children in lane 
                        for (k = 0; k < lane.children.length; k++) { 
                            //get the children in lane 
                            var child = lane.children[k]; 
Shyam G 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon