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

Treeview expand arrow is not disappearing when there are no children to load

3 Answers 506 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Pakeeru
Top achievements
Rank 1
Pakeeru asked on 09 Jul 2012, 02:57 PM
Hello I am using Kendo UI Treeview and loading the nodes dynamically from a Json Data source.The nodes are getting loaded correctly, but when i expand a node it is calling the webapi, if it does not have any child nodes it is not suppose to show the arrow, but it is. Can anybody help me suggest some solution?

Thanks

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 11 Jul 2012, 06:22 AM
Please refer to the binding to remote data and binding to OData service demos, and make sure that you are using the Q2 release. If the problem persists, feel free to open a support ticket and supplying the project that you are having problems with.

All the best,
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
Pakeeru
Top achievements
Rank 1
answered on 13 Jul 2012, 01:58 PM
I was able to resolve some of it with the help of telerik support.

 "hasChildren" is supposed to be a field in the model, means, we should have hasChildren or any field which gets the whether it has children or not, and map that field hasChildren property of the datasource.

in the case if  we don't have hasChildren or any field which gets whether we have children for that node field in the model we can follow as below.

see below for the code, where i have written a function which takes data as parameter, inside the function i am checking necessary field for the condition on which i am deciding whether it can have children or not .
var
 ChildNodes = {             schema: {                 model: {                     id: "NodeID",                     fields: {                         DocumentID: { type: "number" }                     },                     hasChildren: function (data) {                         if (data.DocumentID > 0) {                             return false;                         }                         else {                             return true;                         }                     },                     children: ChildNodes                 }             },             transport: {                 read: {                     url: function (options) {                         var urlstring = document.location.pathname + "/api/node/?ParentID=" + options.NodeID;                         return urlstring;                     },                     dataType: "json"                 }             }         };
0
Mike Rybnikov
Top achievements
Rank 1
answered on 14 Nov 2012, 05:30 PM
Can't really get what's the easiest solution when you need to bind to a service, similar to this:
    public class BrowserController : Controller
    {
        public ActionResult Containers(string id)
        {
            return Json(GetModel(id));
        }
  
        private static object[] GetModel(string id)
        {
            switch (id) // assume to be external WCF call
            {
                case null:
                    return new[] {new {Id = "$", Name = "$"}};
                case "$":
                    return new[] { new { Id = "$/1", Name = "1" }, new { Id = "$/2", Name = "2" } };
                case "$/1":
                    return new[] { new { Id = "$/1/3", Name = "3" }, new { Id = "$/1/4", Name = "4" } };
                default:
                    return new object[0];
            }
        }
}
Tags
TreeView
Asked by
Pakeeru
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Pakeeru
Top achievements
Rank 1
Mike Rybnikov
Top achievements
Rank 1
Share this question
or