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

[Solved] Create tree view from a Dictionary<string, Dictionary<string, List<string>>>

1 Answer 63 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.
bogus
Top achievements
Rank 1
bogus asked on 07 Nov 2010, 02:45 PM
My model is a Dictionary<string, Dictionary<string, List<string>>> , how can i create a three level tree view from it?
Looking at the source it is obvious that i must get something like this :
R1
     C1
          O13
          O22
          O18
     C2
          O3
          O5
R2.....

 

1 Answer, 1 is accepted

Sort by
0
Bobby
Top achievements
Rank 1
answered on 17 Feb 2012, 07:38 PM
Anyone have any ideas?

Where "Testing" should be setting.Key or setting.Value but I cannot seem to get it to work.

@(Html.Telerik().TreeView()
    .Name("TreeView")
    .BindTo(new[] { (ConfigurationLevel) ViewBag.Preview }, mappings =>
    {
        mappings.For<ConfigurationLevel>(binding =>
            binding.ItemDataBound((item, level) => { item.Text = level.Name; })
                .Children(c => c.Settings)
                .Children(c => c.Children.Values)
            );
        mappings.For<SerializableDictionary<string, string>>(binding =>
                binding.ItemDataBound((item, setting) => { item.Text = "Testing"; })
                                                                             
            );
    })
                 
)

I also tried to change the SerializeableDictionary<string, string> to KeyValuePair<string, string> but that doesn't work... I know I'm missing something but it's Friday and it's not clicking.
Tags
TreeView
Asked by
bogus
Top achievements
Rank 1
Answers by
Bobby
Top achievements
Rank 1
Share this question
or