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

OrgChart Layout Refresh After Opening/Closing Children

1 Answer 41 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 10 May 2013, 07:08 PM
I've gone by the example code for the organizational chart and I have everything working except for when you open or close the children nodes I can't get it to re-do the layout - like when "Layout After Expand/Collapse" checkbox is checked in the demo.

What part makes that work? I didn't set up a Router view model - do I need one?

The problem that I find with the demos sometimes is that they do TOO much. Simple examples are much easier to follow, but I can't find one that explains everything you need to have the layout update when nodes are added/removed... everything is laid out fine when it loads, but the nodes never move...

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 15 May 2013, 06:12 AM
Hello Barry,

 I am not sure whether you follow the example code strictly. However, you might need to invoke the Layout in Dispatcher, this way you ensure that the expanded items are loaded in the visual tree. In our OrgChart demo, an event is fired from the ViewModel when an item is expanded or collapsed:

private void GetViewModelAndBindForEvents()
        {
            this.viewModel = this.RootGrid.Resources["ViewModel"] as OrgChartViewModel;
            this.viewModel.ChildTreeLayoutViewModel.LayoutSettingsChanged += (_, __) => this.LayoutOrgChart(false);
            this.viewModel.ChildrenExpandedOrCollapsed += this.OnViewModelChildrenExpandedOrCollapsed;
        }
private void OnViewModelChildrenExpandedOrCollapsed(object sender, EventArgs e)
        {
            if (this.viewModel.ShouldLayoutAfterExpandCollapse == true)
            {
                this.LayoutOrgChart(false);
            }
            this.navigationPane.RefreshThumbnail();
        }
We encourage you to take the full source code from our Git Hub Repository. This way you will be able to debug better and to check how things happen better.

All the best,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

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