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

Child Plus Sign not showing

3 Answers 196 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 21 Dec 2012, 05:43 PM
I have a Root node I can click and make a call to Controller to get Data........that works no problem and the Children are displayed. However on the Server I load those childrens "Items" and set the hasChildren to True. I have verified through the Response data that the Json values are set correctly. However when the nodes are displayed there are no Plus buttons displayed so I can drill down into the data. Only the child text is displayed.

I tried to set LoadOnDemand to False and the plus buttons did show up. But behind the scenes the same call to the Conroller kept being called and eventually my browser locked up.........so not sure why that happened either.

I am converting to Kendo Treeview from Telerik treeview and only thing I really had to do was update to use the TreeViewItemModel object and set the right attributes.

By the way using version 2012.3.1114.340.

Any help would be appreciated.

thanks

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 24 Dec 2012, 06:53 AM
Hello Shawn,

Please see the "remote data" example in the offline demos -- it shows how to load child nodes asynchronously. If it differs from your scenario, try modifying it until it matches it -- and let us know how to reproduce the problem so we can help.

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Shawn
Top achievements
Rank 1
answered on 03 Jan 2013, 07:28 PM
Are you talking about this link - http://demos.kendoui.com/web/treeview/remote-data.html

Here is some code tha may help
 @(Html.Kendo().TreeView()
                .Name("KendoQuoteTree_#=Id#")      
               .DataTextField("Text")
               .DataImageUrlField("ImageUrl")
               .DataUrlField("Url")              
               .DataSource(dataSource => dataSource
                                             .Read(read => read.Action("KendoGetInfo","Info",new { id = "#=Id#" })
                                             .Data("GetOtherParamsl")  //JavaScript Call to return values
                                             )                                                                     
         .ToClientTemplate() 
          )

In the grid I'm able to click the root node and call is made to the controller.  The only thing I'm doing is loading the Child first.  Then that Childs Children in the Items List.  But when its displayed I just see the Children and no Plus sign to expand to see the other children.  Its like the control doesnt recognize there are items associated with each child.  Is this suppose to work this way or do you need to make a call back to server to get children.  I also tried to just load the first level children with the HasChildren flag set to True and still no Plus sign so that I can drill down.

 public JsonResult KendoGetInfo(Guid id,string  param1,string param2)
        {
            return Json(TestTreeBuilder.GetKendoSearchTreeFor(id, "", "", Url), JsonRequestBehavior.AllowGet);        
        }

 public IEnumerable<Kendo.Mvc.UI.TreeViewItemModel> GetKendoSearchTreeFor(Guid d, string param1, string parm2, UrlHelper urlHelper, bool includeDetail = false)
        {
            var nodes = InfoDao.GetNodes(Id);
            var treeNodes = new List<Kendo.Mvc.UI.TreeViewItemModel>();
            var imageUrl = urlHelper.Content(Images.Misc);

            foreach (var dto in nodes.OrderBy(q => q.Number))
            {
                var item = new Kendo.Mvc.UI.TreeViewItemModel
                {
                    Text = string.Format("{0} {1} [{2}]", dto.Number, dto.Name, dto.CurrentStatus),
                    Id = dto.Id.ToString(),
                    ImageUrl = imageUrl,
                    Url = urlHelper.Action("Edit", "Item", new { id = dto.Id }),
                    Expanded = false;                    
                };                
               
                AddChildren(item);
                treeNodes.Add(item);
            }

            return treeNodes;
        }

We use this exact same code when populating the Telerik Treeview.  Only difference we are populating Kendo.Mvc.UI.TreeViewItemModel.

0
Alex Gyoshev
Telerik team
answered on 04 Jan 2013, 05:04 PM
Hello Shawn,

The Kendo UI for ASP.NET MVC comes with offline examples that showcase how to use the widgets in ASP.NET MVC. The examples can be found in the wrappers/aspnetmvc/ folder of the distribution.

I'm attaching a sample project that isolates the remote binding example, to illustrate how the binding works. Please see if the data-bound code that you use follows the same pattern.

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TreeView
Asked by
Shawn
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Shawn
Top achievements
Rank 1
Share this question
or