Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Deleting container node not deleting the children side that (Read 2578 times)
Kiran B
Full Member
***
Offline


I Love MindFusion!

Posts: 102
Joined: Apr 19th, 2013
Deleting container node not deleting the children side that
Apr 24th, 2013 at 9:48am
Print Post  
Hi,

When i try to delete the container node which is having nested children, it is deleting the container from diagram but not the nested children.

How can i achieve this? Ideally it has to be included in the Mindfusion framework right?

I am using below code to remove the item

function removeSelection() {

        var diagram = $find("diagramView1");
        var selectedItems = diagram.getSelection(); //returns both nodes and links

        if (selectedItems) {
            for (var i = selectedItems.items.length - 1; i >= 0; i--) {
                if (selectedItems.items[i]) {
                    diagram.removeItem(selectedItems.items[i]);
                }
            }
        }
    }

Thanks
Kiran B
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Deleting container node not deleting the children side that
Reply #1 - Apr 24th, 2013 at 10:39am
Print Post  
Hi,

This function removes a container togehter with child nodes, handling nested containers too:

Code
Select All
function removeItem(item)
{
	if (item.children)
	{
		Array.forEach(item.children, function (child)
		{
			removeItem(child);
		});
	}
	item.getParent().removeItem(item);
} 



Quote:
Ideally it has to be included in the Mindfusion framework right?


Not necessarily, keeping the child nodes seems a valid enough use case Smiley

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Kiran B
Full Member
***
Offline


I Love MindFusion!

Posts: 102
Joined: Apr 19th, 2013
Re: Deleting container node not deleting the children side that
Reply #2 - Apr 24th, 2013 at 11:43am
Print Post  
Hi Stoyan,

I agree with your point "keeping the child nodes seems a valid enough use case"
But can't you expose a property to configure that?

Because deleting children while deleting the container is also a valid use case. Probably this is the straight forward use case.

What you say?

Thanks
Kiran B
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Deleting container node not deleting the children side that
Reply #3 - Apr 25th, 2013 at 5:41am
Print Post  
We'll have it in mind for next releases Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint