How to set children in kendo.observableHierarchy()?

3 posts, 0 answers
  1. Marco
    Marco avatar
    4 posts
    Member since:
    Feb 2017

    Posted 21 Apr 2017 Link to this post

    In a non-MVVM enviroment, I can define the child entities of my hierarchical datasource by setting the schema:

    var datasource = new{  
        data: [ /*... */ ],  
        schema: { 
            model: {
                children: "Assets"


    In a viewModel I am defining the same datasource like this:

    function buildDataSource(data) {, function(item) {
            item.type = "folder";
       var tree = unflatten(data.assets);
       return tree;
    function loadTreeView(dataSource) {
        documentsModel.set("treeviewSource", kendo.observableHierarchy(dataSource));
        kendo.bind($("#Treeview"), documentsModel);
         dataType: "json",
         url: "scripts/assets.json"


    What is happening here, that I am loading a flat array of json objects from a file (later api endpoint) and unflatten this list, so it is in a hierachical format. The method to unflatten this array is naming the children "Assets". Running this, the treeview fails to display. If I change the unflatten method to name those children "items", the treebiew works.

    You can reproduce this in this Dojo:

    Change items, to anything else and it stops working. How can I configure the kendo.observableHierarchy, so it uses any other property then "items" to determine if an object has children using a viewModel?

  2. Plamen
    Plamen avatar
    2893 posts

    Posted 25 Apr 2017 Link to this post


    I have set the model in the sample that you provided and it worked correctly at my side. Here is the updated dojo page. Please let me know if you have your scenario is somehow different.

    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Marco
    Marco avatar
    4 posts
    Member since:
    Feb 2017

    Posted 25 Apr 2017 in reply to Plamen Link to this post

    Ah the schema was, what I was missing.


    Thanks a lot - you deserve a beer :)

Back to Top