I suggest you ...

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 vote
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    jpvjpv shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    0 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base