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

Problems with RadTreeView

8 Answers 107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
paul
Top achievements
Rank 1
paul asked on 23 Jul 2008, 08:29 AM
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.

8 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 23 Jul 2008, 08:54 AM
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
0
paul
Top achievements
Rank 1
answered on 23 Jul 2008, 09:07 AM
Thanks for your qucik reply. I will have a look at the example.

Regards,

Paul Chapman
0
paul
Top achievements
Rank 1
answered on 23 Jul 2008, 01:12 PM
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
0
Valentin.Stoychev
Telerik team
answered on 24 Jul 2008, 02:53 PM
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.
0
paul
Top achievements
Rank 1
answered on 25 Jul 2008, 10:41 AM
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.
0
Valentin.Stoychev
Telerik team
answered on 25 Jul 2008, 11:04 AM
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.
0
Ben Hayat
Top achievements
Rank 2
answered on 25 Jul 2008, 01:26 PM
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!
0
Valentin.Stoychev
Telerik team
answered on 25 Jul 2008, 01:41 PM
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.
Tags
General Discussions
Asked by
paul
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
paul
Top achievements
Rank 1
Ben Hayat
Top achievements
Rank 2
Share this question
or