OrgChart Layout Refresh After Opening/Closing Children

2 posts, 0 answers
  1. Barry
    Barry avatar
    90 posts
    Member since:
    Jul 2011

    Posted 10 May 2013 Link to this post

    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...
  2. Petar Mladenov
    Petar Mladenov avatar
    2991 posts

    Posted 15 May 2013 Link to this post

    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)
    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.

Back to Top