Populating OrgChart on event

4 posts, 0 answers
  1. David
    David avatar
    3 posts
    Member since:
    May 2012

    Posted 30 May 2012 Link to this post

    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);
                }
     
                    
            }

     

     

     

     

  2. David
    David avatar
    3 posts
    Member since:
    May 2012

    Posted 30 May 2012 Link to this post

    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..
  3. DevCraft banner
  4. David
    David avatar
    3 posts
    Member since:
    May 2012

    Posted 31 May 2012 Link to this post

    Found it: PopulateGraphSource was the problem. Now doing it manually and it works.
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 31 May 2012 Link to this post

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

Back to Top