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

Populating OrgChart on event

3 Answers 80 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 30 May 2012, 10:06 AM
Hi,
im trying to modify the default OrgChart example. I have a subclass wich is loading the defaut organization.xml from web. Once the download and XML-parsing is complete, a PropertyChanged event is fired. Unfortunately, all shapes are stacked in the upper left corner and the connection lines are messed up: The most outer nodes have no connections any more and the other node connections are all directing in the left upper corner. Same problems with the default demo code (embedded XML) when im trying to set the graph source from the event handler. Everything is fine when im moving the populateGraphSource-calls back to the ViewModel-Constructor. Tested with the demo XML-code.

My modified viewmodel looks like this:

 

       

public OrgChartViewModel()
{
         
            this.ToggleVisibilityCommand = new DelegateCommand(this.ExecuteToggleVisibilityCommand, this.CanExecuteToggleVisibilityCommand);
            _Repository.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_Repository_PropertyChanged);
           
}
  
void _Repository_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {            
                case "OrganizationXML":
                    
            this.GraphSource = new GraphSource();
            this.HierarchicalDataSource = new ObservableCollection<Node>();
            this.PopulateWithData();         
            this.GraphSource.PopulateGraphSource(this.HierarchicalDataSource[0]);
 
                    break;
                default:
                    break;
            }
 
        }
 
private void PopulateWithData()
        {
    
 
        foreach (XElement element in _Repository.OrganizationXML.Elements("Node"))
               
            {
                Node node = this.CreateNode(element);
                node.Children.AddRange(this.GetSubNodes(element));
                this.HierarchicalDataSource.Add(node);
            }
 
                
        }

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 30 May 2012, 01:18 PM
Somehow i got it working that the chart is populated from the event handler. Still strange: Every node, that has one ore more subnodes, has an extra line to the upper left corner..
0
David
Top achievements
Rank 1
answered on 31 May 2012, 10:46 AM
Found it: PopulateGraphSource was the problem. Now doing it manually and it works.
0
Petar Mladenov
Telerik team
answered on 31 May 2012, 02:46 PM
Hi David,

 We are glad to know that you have resolved this on your known. We just wanted to let you know that you can expect a lot of improvements in our new OrgChart example. It will be released with the Q2 2012 in the first half of June. So please stay tuned for the update.

Greetings,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

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