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

TreeView + Hierachiel DataSource fail to load childs

1 Answer 214 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ahmed
Top achievements
Rank 1
Ahmed asked on 11 Oct 2012, 10:11 AM
Hi, I'm new in using Kendo UI ,
I've tried to use the  Binding to remote data example on localhost. but it always load in the first time ,and it hangs on loading the childs
firebug shows the request to the service done successfully ,

I also notices that the service request for the online example appears in  the XHR Tab in firebug, but in my test project appear in the JS tab , can anyone explain to me Why??

1 Answer, 1 is accepted

Sort by
0
Vladymyr
Top achievements
Rank 1
answered on 14 Nov 2012, 12:24 PM
Hi everybody,

I have the same problem: only the first level items are shown, but children items are not shown
I did exactly as given in the kendoui remote-binding treeview example:
In the View I specified the code as follows:
@(Html.Kendo().TreeView()
                      .Name("treeview")
                      .DataTextField("Name").DragAndDrop(true)
                      .DataSource(dataSource => dataSource
                            .Read(read => read
                                          .Action("TreeViewBranch","Attribute")
                             )
                       )
                  )
In the Controller I specified the code as follows:
 public JsonResult TreeViewBranch(int? id)
        {
            var attr = from a in
                           (from a1 in db.Attributies
                            join a2 in db.Attributies on a1.Id equals a2.ParentId into ag
                            from aa in ag.DefaultIfEmpty()
                            where (id.HasValue ? a1.ParentId == id : (a1.ParentId == null) || (a1.ParentId == 0))
                            select new { Id = a1.Id, Name = a1.Name, hasPar = aa.Id != null?1:0 })
                       group a by new { a.Id, a.Name } into ga
                       select new { Id=ga.Key.Id,Name=ga.Key.Name,hasParent=ga.Max(a=>a.hasPar)!=0};
            return Json(attr, JsonRequestBehavior.AllowGet);
        }
I verified the results produced by this controller in the browser and it is the same as produced in the kendoui example (I used Firebug to check the json data)
When the page is loaded, the first request is Ok:
[{"Id":1,"Name":"Interests","hasParent":true},{"Id":2,"Name":"TV Content","hasParent":true}]
As a result, 2 items are shown in the treeview: "Interests" and "TV Content", but no array sign to open these items.
When I clicked on these items, no further requests are generated to fetch children items.
The FIrebug console does not notify of any exceptions or problems in Javascript code.
So, the treeview does not work remotely (I tried statical (basic) version of treeview (which has data in html structure without remote binding)- and it works fine).
I will appreciate it if you help us solve this problem as soon as possible?
Our company is about to make a decision to buy Kendoui licence.

Tags
TreeView
Asked by
Ahmed
Top achievements
Rank 1
Answers by
Vladymyr
Top achievements
Rank 1
Share this question
or