Kendo UI Treeview不在setDataSource上显示数据(加载后)

时间:2013-07-08 11:02:33

标签: kendo-ui kendo-treeview

我有一个Treeview,可以在页面加载时加载,但是我想将树过滤到所选节点,所有功能似乎都在100%工作,但是当我尝试使用时,它不会在树上显示任何内容即使json正在返回,也应用过滤器。我希望我有意义。 这是我的代码:

<div id="treeview"></div>
<script>
    var selectedId;

    var homogeneous = new kendo.data.HierarchicalDataSource({
        transport: {
            read: {
                url: "/loadtree",
                dataType: "json"
            }
        },
        schema: {
            model: {
                id: "Id",
                hasChildren: "hasChildren"
            }
        }
    });

    $("#treeview").kendoTreeView({
        dataSource: homogeneous,
        dataValueField: "Id",
        dataTextField: "Name",
        select: onSelect

    });



    function onSelect(e) {
        var tv = $("#treeview").data("kendoTreeView").dataItem(e.node);
        $("#details-container").load("entitydetail/" + tv.Id);
        selectedId = tv.Id;

    }

    function loadTreetoSelected()
    {

        newdata = new kendo.data.HierarchicalDataSource({
            transport: {
                read: {
                    url: "/loadtreetoselected/" + selectedId,
                    dataType: "json",
                }

            },
            schema: {
                model: {
                    id: "Id",
                    hasChildren: "hasChildren"
                }
            }
        });

        $("#treeview").data("kendoTreeView").setDataSource(newdata);    

    }       

</script>

<input type="button" value="Filter to Selected" onclick="javascript: loadTreetoSelected();" />

,这是返回的json:

{"Id":7932,"Name":"OPC 2013","hasChildren":true}

感谢您的帮助

0 个答案:

没有答案