将树扩展到第一级

将树扩展到第一级

In this jsfiddle我的Kendo TreeView使用


treeView.expand(“。k-item”);


但是,我要寻找的只是将树扩展到第一级(不更改数据源)。这可能吗?

HTML:

<div id="treeview"></div>


Javascript:

   var treeView = $("#treeview").kendoTreeView({
         dataSource: ds,
         dataTextField: ["Name"],
    }).data("kendoTreeView");


    treeView.expand(".k-item");


    var ds = [
       {
        "Name": "Child 3",
        "items": [
            {
                "Name": "Leaf 1"

            },
            {
                "Name": "Leaf 2"

            },
            {
                "Name": "Leaf 3"

            },
            {
                "Name": "Leaf 4"

            },
            {
                "Name": "Leaf 5"

            },
                    {
                        "Name": "Child 4",
                        "items": [
                            {
                                "Name": "Leaf 8"

                            },
                            {
                                "Name": "Leaf 9"

                            },
                            {
                                "Name": "Leaf 10"

                            }
                        ]
                    }
             ]
        }

   ];

最佳答案

有点奇怪,但是您可以使用'child'CSS选择器仅选择1级深度的节点:

treeView.expand("> .k-group > .k-item");

关于jquery - KendoTreeView:如何将树扩展到第一级?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27385922/

10-09 23:08