Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic MindFusion javascript delete child nodes (Read 2547 times)
dipak patil
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 1
Joined: Jul 19th, 2016
MindFusion javascript delete child nodes
Jul 19th, 2016 at 4:52am
Print Post  
Hi,

In flow diagram how to delete child nodes on deletion of parent node.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: MindFusion javascript delete child nodes
Reply #1 - Jul 19th, 2016 at 7:07am
Print Post  
Hi,

If you mean child nodes in a tree, you could delete all descendant recursively from Events.nodeDeleting handler -

Code
Select All
function onNodeDeleting(sender, args)
{
	deleteDescendants(args.getNode());
}

function deleteDescendants(node)
{
	var links = node.getOutgoingLinks().slice();
	links.forEach(function (link)
	{
		var child = link.getDestination();
		deleteDescendants(child);
		child.parent.removeItem(child);
	});
} 



If you need to delete child nodes of a ContainerNode -

Code
Select All
function onNodeDeleting(sender, args)
{
	var node = args.getNode();
	if (node.children)
		deleteContent(node);
}

function deleteContent(container)
{
	var children = container.children.slice();
	children.forEach(function (child)
	{
		if (child.children)
			deleteContent(child);
		child.parent.removeItem(child);
	});
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint