Problems with RadTreeView

9 posts, 0 answers
  1. paul
    paul avatar
    16 posts
    Member since:
    Jul 2008

    Posted 23 Jul 2008 Link to this post

    Hi,

    We're currently trying to use the RadTreeView to display some hierarchial data. I've created a hierarchial list of my flat data.

        public class OidInfo 
        { 
            private List<OidInfo> _children = new List<OidInfo>(); 
            private string _parent; 
     
            public OidInfo() 
            { 
            } 
     
            public OidInfo(string oid, string name) 
            { 
                OID = oid; 
                Name = name; 
            } 
     
            public List<OidInfo> Children 
            { 
                get { return _children; }  
                set { _children = value; } 
            } 
     
            public string OID { getset; } 
            public string Name { getset; } 
     
            public string Parent 
            { 
                get 
                { 
                    if (string.Compare(OID, "1.3.6.1.4.1.28812") == 0) 
                        return ""
     
                    string[] split = OID.Split('.'); 
     
                    var sb = new StringBuilder(); 
                    for (var i = 0; i < split.Length - 1; i++) 
                    { 
                        if (i != 0) 
                            sb.Append("."); 
     
                        sb.Append(split[i]); 
                    } 
     
                    return sb.ToString(); 
                } 
                set { _parent = value; } 
            } 
     
            public override string ToString() 
            { 
                return string.Format("{0} {1} {2}", OID, Name, Parent); 
            } 
        } 

    When I step through my code I have created the hierarchial list correctlty with each node having its parent and child lists correctly populate. When I bind the RadTreeView to the list it only displays the root element. Is it possible to use string type for id's?

    Regards,

    Paul.
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 23 Jul 2008 Link to this post

    Hi paul,

    You need to set HierarchicalDataTemplates for the treeview.

    Check-out this online examples:
    http://www.telerik.com/demos/Silverlight/#Examples/TreeView/DataBinding

    You have the example in the distribution also.


    Sincerely yours,
    Valentin.Stoychev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. paul
    paul avatar
    16 posts
    Member since:
    Jul 2008

    Posted 23 Jul 2008 Link to this post

    Thanks for your qucik reply. I will have a look at the example.

    Regards,

    Paul Chapman
  4. paul
    paul avatar
    16 posts
    Member since:
    Jul 2008

    Posted 23 Jul 2008 Link to this post

    I now have my treeview bound to my data as expected. I'm now facing another problem that I have seen mentioned in this forum.

    I load a list of values from the database and provide them to my control via web services. These values correspond to the 'Value' member of the bound objects.

    I want to iterate through the tree and if the treeviewitem's object 'Value' member equals our persisted value, check the items checkbox.

    Likewise, when the control is close I want to persist a list of checked values back to the database.

    What is the best way of acheiving this?

    Regards,

    Paul
  5. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 24 Jul 2008 Link to this post

    Hi Paul,

    First of all - in the next release of the RadTreeView we will add CheckedNodes which will fit in your scenario.

    For the moment - you should get a list of all items and check their IsChecked property.

    You can get all items by using the following code:
    Collection<RadTreeViewItem> GetAllItemContainers(ItemsControl itemsControl)  
            {  
     
                Collection<RadTreeViewItem> allItems = new Collection<RadTreeViewItem>();  
     
                for (int i = 0; i < itemsControl.Items.Count; i++)  
                {  
                    RadTreeViewItem childItemContainer = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as RadTreeViewItem;  
                    if (childItemContainer != null)  
                    {  
                        allItems.Add(childItemContainer);  
     
                        Collection<RadTreeViewItem> childItems = GetAllItemContainers(childItemContainer);  
                        foreach (RadTreeViewItem childItem in childItems)  
                        {  
                            allItems.Add(childItem);  
                        }  
                    }  
                }  
                return allItems;  
            } 

    Please let us know if you need more help on that.

    Best wishes,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. paul
    paul avatar
    16 posts
    Member since:
    Jul 2008

    Posted 25 Jul 2008 Link to this post

    Thanks for your reply, that solves my problem. I assume that the 'IsChecked' property you talk about is the item.CheckState property?

    Due to your rapid support we have decided to use your controls in our product and you will be receiving an order for the SL controls when they become available.

    Kind Regards,

    Paul Chapman
    Digitalk Limited.
  7. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 25 Jul 2008 Link to this post

    Hi Paul,

    Yes - I meant the CheckState property, sorry about that.

    We are very glad to know that you will use our controls in a production environment. Let us know if you need any special , so we can fit in our schedule. Very soon we willl start our early adopter program which you can use to send us your feedback/bug report/feature requests and you will be able to get a discount from the price of the suite if you are acively participating. But more info on that program will be available next week.


    All the best,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. Ben Hayat
    Ben Hayat avatar
    902 posts
    Member since:
    May 2008

    Posted 25 Jul 2008 Link to this post

    vvvvvvvvvvv
    Due to your rapid support we have decided to use your controls in our product and you will be receiving an order for the SL controls when they become available.
    ^^^^^^^^^
    Paul;
    I've reached to the same conclusion as well!

    vvvvvvvvvvvvv
    Very soon we will start our early adopter program which you can use to send us your feedback/bug report/feature requests and you will be able to get a discount from the price of the suite if you are acively participating. But more info on that program will be available next week.
    ^^^^^^^^^^^
    Valentin;
    I'm interested to know as well. Please keep me posted!
    Thanks!
  9. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 25 Jul 2008 Link to this post

    Hi Ben,

    The adoption program is for everyone. We just need a couple of more days to shape it and make it public.


    Greetings,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top