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

[Solved] Can't get "Nested Children" to work.

0 Answers 35 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dakota
Top achievements
Rank 1
Dakota asked on 22 Jul 2011, 05:55 PM
Before we start, I've already read over :

http://www.telerik.com/community/forums/aspnet-mvc/treeview/treeview-children-recursion.aspx
http://www.telerik.com/community/forums/aspnet-mvc/treeview/bind-to-model-could-be-better.aspx

To no avail (if I've overlooked something specific in there that I'm missing please let me know!) I have 3 simple tables in a database and I'm having problems populating the 3rd tier (2nd child). Any tips? 

In summary the Tree should be like this..

Contract Description
         Member FirstName, LastName of the Contract
                    EpisodeID of each Member.

BTW, just one child works...  For example this works...


@(
Html.Telerik().TreeView()
       .Name("myTree")
       .BindTo(Model, mappings =>
         {
           mappings.For<Model.Contract>(binding => binding
             .ItemDataBound((item, contract) =>
               {
                 item.Text = contract.Description;
               })
               .Children(contract => contract.Members));
           mappings.For<Model.Member>(binding => binding
             .ItemDataBound((item, member) =>
               {
                 item.Text = member.FirstName + " " + member.LastName;
               }));
         })
)



But this does not...

Html.Telerik().TreeView()
       .Name("myTree")
       .BindTo(Model, mappings =>
         {
           mappings.For<Model.Contract>(binding => binding
             .ItemDataBound((item, contract) =>
               {
                 item.Text = contract.Description;
               })
               .Children(contract => contract.Members));
           mappings.For<Model.Member>(binding => binding
             .ItemDataBound((item, member) =>
               {
                 item.Text = member.FirstName + " " + member.LastName;
               })
               .Children(member => member.Episodes));
           mappings.For<Model.Episode>(binding => binding
             .ItemDataBound((item, episode) =>
               {
                 episode.Text = episode.episodeid;
               }));
         })
)
Tags
TreeView
Asked by
Dakota
Top achievements
Rank 1
Share this question
or