jquery - 剑道 TreeView : how to expand tree up to the first level?

标签 jquery kendo-ui

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"

                            }
                        ]
                    }
             ]
        }

   ];

最佳答案

这有点奇怪,但您可以使用“子”CSS 选择器来仅选择 1 级深度的节点:

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

关于jquery - 剑道 TreeView : how to expand tree up to the first level?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27385922/

相关文章:

javascript - 这 2 种方法哪种更有效?

c# - Selenium Internet Explorer 驱动程序、Kendo Mobile 和 Octopus Deploy

css - 输入字段上的 Kendo UI 按钮未对齐

javascript - 如何从 Kendo-multiSelect 中获取选定值?

jquery - CSS 在确切日期后淡出

javascript - 我们如何在动态插入的输入上设置掩码?

javascript - jQuery 中的 addClass 不添加类

javascript - 当包含为 asp 文件时,Bootstrap Dropdowns 将展开,但不会关闭

javascript - Bootstrap 3 和 KendoUI 的 Jquery 问题

jquery - Kendo UI 数字格式模板无效