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

TreeView with Remote Databinding example using Id that is a string

1 Answer 201 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Carrie
Top achievements
Rank 1
Carrie asked on 18 Sep 2013, 09:22 PM
Hello,

I am trying to implement a TreeView using remote binding.  My datasource Id property is actually a string not an integer - I am having trouble getting this working - can you advise where I am going wrong?    My code is below.

Thanks,
Carrie

View
@(Html.Kendo().TreeView()
     .Name("treeviewTierQueue")
     .DataTextField("Text")
     .DataSource(dataSource => dataSource
              .Read(read => read.Action("GetTierQueueList", "Enum"))
  ))
Controller
public JsonResult GetTierQueueList(string level)
{
    var items = new List<NestedSelectListItem>()
        {
            new NestedSelectListItem {Id = "0", Text = "All Analysts"},
            new NestedSelectListItem {Id = "1", Text = "All Groups"},
            new NestedSelectListItem {
                Id = "2",
                Text = "Service Desk",
                hasChildren=true,
                Items = new List<NestedSelectListItem> ()
                {
                    new NestedSelectListItem {Id = "2a", Text = "2nd Level"},
                    new NestedSelectListItem {Id = "2b", Text = "2nd Level B"},
                    new NestedSelectListItem {
                        Id = "2c",
                        Text = "2nd Level C",
                        hasChildren= true,
                        Items = new List<NestedSelectListItem> ()
                        {
                            new NestedSelectListItem {Id = "3a", Text = "3rd Level"},
                            new NestedSelectListItem {Id = "3b", Text = "3rd Level B"}
                        }
                  } } }
        };
 
    if (!String.IsNullOrEmpty(level))
    {
        var filtered = items.First(i => i.Id == level).Items;
        items = filtered;
    }
 
    return Json(items.AsEnumerable(), JsonRequestBehavior.AllowGet);
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Carrie
Top achievements
Rank 1
answered on 19 Sep 2013, 05:45 PM
I resolved the issue by renaming the passed in parameter from "level" to "Id".

Thanks,
Carrie
Tags
TreeView
Asked by
Carrie
Top achievements
Rank 1
Answers by
Carrie
Top achievements
Rank 1
Share this question
or