I try with this code but it is not rendering childs:
My GetTreeViewData is:
I also try to experiments with hasChildren, children, loadOnDemand properties, without success.
What I am doing wrong?
<
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
>
<?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?