This is a migrated thread and some comments may be shown as answers.

Layout not working for custom pasted nodes

1 Answer 55 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Aakansha
Top achievements
Rank 1
Aakansha asked on 17 Nov 2014, 12:57 PM
Suppose I copied a sub-tree and pasted on another node. It got pasted. But the bounds it take as 0,0 so all the nodes and its children appear on top of each other.
To fix this, in my MyCustomPaste() function, I called the same function which telerik has called in mind map diagram demo for layout.

So my aim is to call any default layout so that nodes get realigned into appropriate position once the pasting of new nodes is done.

settings.Roots.Add(this.diagram.ContainerGenerator.ContainerFromItem(this.maintViewModel.Source.Items.OfType<object>().ElementAt(0)) as IShape);
this.diagram.Layout(LayoutType.Tree, settings);
this.diagram.AutoFit();

This layout works for the remaining of the nodes which have not been touched by my custom cut and copy function. But the rest of the children of the node which is copied, still come on top of each other. Any fix for this?

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 19 Nov 2014, 11:43 AM
Hi Aakansha,

Could you please check in your code whether the following line returns null:
this.diagram.ContainerGenerator.ContainerFromItem(this.maintViewModel.Source.Items.OfType<object>().ElementAt(0))
It might be too early after paste and the container might not have been generated yet.

Also could you please try LayoutAsync instead of Layout and let us know if this layouts the shapes correctly ?

Regards,
Petar Mladenov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Diagram
Asked by
Aakansha
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or