Declined
Last Updated: 13 Jun 2013 17:40 by ADMIN
J.P
Created on: 24 Nov 2011 00:28
Category: Kendo UI for jQuery
Type: Feature Request
1
Building a tree with an object.
A direct and simple way to build a tree from an Object : 
Work fine like that but a shorter way would be better
a.k.a ~ $("#mytree").kendoTreeView({'ObjectSource':myObject)
try this html to have a better idea of what i suggest.
Thanks


<body>
<ul id="mytree"/>
<script>

         $(document).ready(function() {

         		 var myObject = {  "who"    : [ "french", "man", "old geek", { "age": "49", "status" : "with a wonderful wife" } ],
                                       "living" : { "Europe" : { "France" : { "cities" : ["Paris","Bretagne"]}}},
                                       "loving" : [{ "langages": ["KendoUI", "Node.js"]}, { "other" : "chocolate" }]
                                    };


                 var ObjToHtmlUlLi  = function (obj) {
                                            var result = "";
                                            if (obj instanceof Array) 
                                                for (i in obj)
                                                    result += "<li>" + ObjToHtmlUlLi(obj[i]) + "</li>";
                                            else  if (obj instanceof Object)
                                                        for(i in obj)
                                                              result += "<li>" + i + "<ul>"+ObjToHtmlUlLi(obj[i])+"</ul></li>";
                                            else
                                                result += "<li>"+ obj + "</li>";
                                            return result;
                                           };

                $("#mytree").html(ObjToHtmlUlLi(myObject));
             	$("#mytree").kendoTreeView();
                //=> somethins like   $("#mytree").kendoTreeView({'jsonSource':myJsonObject) would be great
        });
</script>
</body>
1 comment
ADMIN
Brandon
Posted on: 13 Jun 2013 17:40
Closing due to a lack of votes