Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > TreeView > Binding Different type of collection to RadTreeView

Not answered Binding Different type of collection to RadTreeView

Feed from this thread
  • Prakash avatar

    Posted on Dec 20, 2011 (permalink)

    Hi Everybody,

    Telerik Version: 2010.2.924.1040

    My Requirement:

    I've a collection in the following format and I want to bind the collection to RadTreeView in similar format.
    I've gone many telerik forums links but didn't find anything related to my problem. Since I'm reaching my deadlines I've created a new thread and If you can provide a example then it will be really useful for me. 

    The following is the sample type which is very close to my business object:
    Mobile
    -- ModelName
    -- Price
    + Sims
       -- Sim1
           -- Number
           + Contacts
       -- Sim2 
           -- Number
           + Contacts
    + Folders
        -- FolderName
        + Files
           -- FileName
           -- Size
           -- Capacity
     
    public class Mobile
        {
            public string ModelName { set; get; }
            public string Price { set; get; }
            public ObservableCollection<Sim> Sims { set; get; }
            public ObservableCollection<Folder> Folders { set; get; }
        }


        public class Sim
        {
            public int Number { set; get; }
            public ObservableCollection<Contact> Contacts { set; get; }
        }


        public class Contact
        {
            public string Name { set; get; }
            public string Address { set; get; }
            public int PhoneNumber { set; get; }
        }


        public class Folder
        {
            public string Name { set; get; }
            public ObservableCollection<File> Files { set; get; }
        }


        public class File
        {
            public string FileName { set; get; }
            public string Size { set; get; }
            public string Type { set; get; }
        }

    Thanks,
    Prakash.

    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on Dec 23, 2011 (permalink)

    Hello,

     Please check out the File / Folder hierarchy demonstrated in the attached project. In your scenario , you have to unite your Sims and Folders collection in a single collection and differentiate them in the Style/Template Selector logic. Please let us know if you need further assistance on this. 

    Greetings,
    Petar Mladenov
    the Telerik team

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

    Attached files

    Reply

  • Prakash avatar

    Posted on Dec 23, 2011 (permalink)

    Hi Petar Mladenov,

    Thanks for the example, I've gone through example but, In the example the child are belong to same type whereas for me all child will be of different type. 

    Root will show list of Mobiles and each mobile object will contain a list of sim and a list folders, both the sim and folder are of entirely different types. Since I may not specific my business objects here, so, I've specified with some common examples.
    It will be like a node with two or more different types of collections and I may not unit this collection to single collection. Please direct me in doing the above requirement. 

    And my tree structure will look like:

    Mobile 1 
    -- ModelName 
    -- Price
    + Sims 
       -- Sim1
           -- Number
           + Contacts
       -- Sim2 
           -- Number
           + Contacts
    + Folders
        -- FolderName
        + Files
           -- FileName
           -- Size
           -- Capacity

    Mobile 2
    -- ModelName 
    -- Price
    + Sims 
       -- Sim1
           -- Number
           + Contacts
       -- Sim2 
           -- Number
           + Contacts
    + Folders
        -- FolderName
        + Files
           -- FileName
           -- Size
           -- Capacity


    Thanks,
    Prakash.

    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on Dec 28, 2011 (permalink)

    Hi Prakash,

     The RadTreeView basically represents hierarchical data but in your case you want something different - for example property of an item to behave like its child. When binding the RadTreeView, every hierarchy level needs objects that inherit from one and the same type. That is why in your case you need to make some of the properties and the child items to inherit from common type. I prepared a possible approach for you and you can examine it in the attached solution.
    On a side note, have you considered using a RadTreeListView?

    Kind regards,
    Petar Mladenov
    the Telerik team

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

    Attached files

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > TreeView > Binding Different type of collection to RadTreeView
Related resources for "Binding Different type of collection to RadTreeView"

Silverlight TreeView Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]