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

Not rendering sub-items when full source is loaded via ajax

1 Answer 48 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Matjaz
Top achievements
Rank 1
Matjaz asked on 19 Sep 2014, 10:17 PM
I try with this code but it is not rendering childs:
<body>
 <div id="main">
    <div data-role="treeview" data-bind="source: test" data-load-on-demand="true"></div>
</div>
  
<script>
$(document).ready(function()
        {
            var MVVM = kendo.observable(
            {
              test: new kendo.data.HierarchicalDataSource(
                        {
                            transport:
                            {
                                read:
                                {
                                    url: "GetTreeViewData.php"
                                }
                            },                         
                        }),
              });
             kendo.bind($('#main'), MVVM);
        });
 
    
</script>
 
</body>
My GetTreeViewData is:
<?php
    $result = [];
 
    $item = new stdClass();
    $item->text = "level 1.1";
    $result[] = $item;
 
    $item = new stdClass();
    $item->text = "level 1.2";
    $item->items = [];
     
    $subitem = new stdClass();
    $subitem->text = "level 2.1";
    $item->items[] = $subitem;
 
    $subitem = new stdClass();
    $subitem->text = "level 2.2";
    $item->items[] = $subitem;
 
    $item = new stdClass();
    $item->text = "level 1.3";
    $result[] = $item;
     
    header('Content-type: application/json;');
    echo json_encode($result); 
?>

I also try to experiments with hasChildren, children, loadOnDemand properties, without success.
What I am doing wrong?

1 Answer, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 23 Sep 2014, 12:26 PM
Hello Matjaz,

In order to bind all levels when the dataSource is loaded, you will need to specify a schema that does this. See this documentation help topic for a demo.

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