Kendo UI Leaf-node问题

时间:2013-06-05 06:37:54

标签: php jquery ajax kendo-ui kendo-treeview

我有这张表http://sqlfiddle.com/#!2/06e35

我正在创建kendo-ui tree http://demos.kendoui.com/web/treeview/remote-data.html

这是我的jQuery代码

        <script>
            var serviceRoot = "search/treej.php";
                homogeneous = new kendo.data.HierarchicalDataSource({
                    transport: {
                        read: {
                            url: serviceRoot,
                            dataType: "jsonp"
                        }
                    },
                    schema: {
                        model: {
                            id: "entity_id",
                            hasChildren: "child"
                        }
                    }
                });

            $("#treeview").kendoTreeView({
                dataSource: homogeneous,
                dataTextField: "value"
            });
        </script>

这是我的treej.php文件

<?php
// database connection

$id_check = $_REQUEST['entity_id'];
$callback = $_REQUEST['callback'];

if($id_check == ''){
    $tree_result = $conn->query("SELECT entity_id, value, parent_id as ReportsTo, child From test2 Where parent_id = 0");
}else{
    $tree_result = $conn->query("SELECT entity_id, value, parent_id as ReportsTo, child From test2 Where parent_id = (".$id_check.")");
}

$data = array();
foreach($tree_result as $row) {
    $data[] = $row;
}

header('Content-Type: application/json');
$j_data =  json_encode($data);
echo $callback.'('.$j_data.')';
?>

问题是叶子节点还显示>,而在数据库中,子节点为false

这是输出

enter image description here

在此图片中,带有红色航空的节点不应显示>展开图标

这里是HTML

    <div class="k-content" id="example">
        <div class="demo-section k-widget k-treeview" id="treeview" data-role="treeview" tabindex="0" role="tree" aria-activedescendant="treeview_tv_active">
        <ul role="group" class="k-group k-treeview-lines">
            <li data-uid="0826702e-556f-4a04-9e16-4e17481d8d7e" class="k-item k-first k-last" role="treeitem" data-expanded="true" aria-expanded="true"><div class="k-top k-bot"><span role="presentation" class="k-icon k-minus"></span><span class="k-in">Root</span></div><ul role="group" class="k-group" style="display: block;">
            <li data-uid="2109e3d0-efdf-4e18-b772-f6d258addd4f" class="k-item" role="treeitem" data-expanded="true" aria-expanded="true"><div class="k-top"><span role="presentation" class="k-icon k-minus"></span><span class="k-in">level 0A</span></div><ul role="group" class="k-group" style="display: block;">
            <li data-uid="320d3043-89b9-4abb-b83b-d34c3ebe8d0b" class="k-item k-last" role="treeitem" data-expanded="true" aria-expanded="true"><div class="k-bot"><span role="presentation" class="k-icon k-minus"></span><span class="k-in">Leval 1-A</span></div><ul role="group" class="k-group" style="display: block;">
            <li data-uid="f17fa56e-6c2c-48ec-b930-2691705a6904" class="k-item" role="treeitem" data-expanded="true" aria-expanded="true"><div class="k-top"><span role="presentation" class="k-icon k-minus"></span><span class="k-in">level 2A</span></div><ul role="group" class="k-group" style="display: block;">
            <li data-uid="e9ff454c-6ce5-4237-9ac5-7a306fb63401" class="k-item" role="treeitem" data-expanded="true" aria-expanded="true"><div class="k-top"><span class="k-in">level 3A1</span></div></li>
            <li data-uid="491243fb-0654-4e8d-8637-f81367c364bf" class="k-item k-last" role="treeitem" data-expanded="true" aria-expanded="true"><div class="k-bot"><span class="k-in">level 3A2</span></div></li></ul></li>
            <li data-uid="025389fa-359c-45af-929e-065d43f3c385" class="k-item k-last" role="treeitem" data-expanded="true" aria-expanded="true"><div class="k-bot"><span role="presentation" class="k-icon k-minus"></span><span class="k-in">level 2B</span></div><ul role="group" class="k-group" style="display: block;">
            <li data-uid="8220eaff-c005-440d-9144-318711c835fc" class="k-item" role="treeitem" data-expanded="true" aria-expanded="true" id="treeview_tv_active"><div class="k-top"><span class="k-in">level 3B1</span></div></li>
            <li data-uid="93afa526-9285-4ea5-be2d-3bc344cb9089" class="k-item k-last" role="treeitem" data-expanded="true" aria-expanded="true"><div class="k-bot"><span class="k-in">level 3B2</span></div></li></ul></li></ul></li></ul></li>
            <li data-uid="86fedc22-c262-48ac-a1ad-c516a69583aa" class="k-item k-last" role="treeitem" data-expanded="true" aria-expanded="true"><div class="k-bot"><span role="presentation" class="k-icon k-minus"></span><span class="k-in">level 0B</span></div><ul role="group" class="k-group" style="display: block;">
            <li data-uid="98b08705-8db6-4759-88a9-d8d468c59fd8" class="k-item" role="treeitem" data-expanded="true" aria-expanded="true"><div class="k-top"><span class="k-in">level 1.1 B</span></div></li>
            <li data-uid="750b5ae2-b445-41e9-95f7-e6e3be396f1d" class="k-item k-last" role="treeitem" data-expanded="true" aria-expanded="true"><div class="k-bot"><span class="k-in">Level 1.2 B</span></div></li></ul></li></ul></li>
        </ul></div>
    </div>

0 个答案:

没有答案