javascript - Kendo UI Treeview - 绑定(bind)到本地数据时更新复选框状态

标签 javascript checkbox kendo-ui kendo-treeview

我有一个带有 的 JavaScript 对象项目 数组来定义层次结构。当我创建 Kendo Treeview 带有此数据的小部件,按需加载设置为 false,本应不确定的复选框显示为未选中。

我解决这个问题的方法是设置 按需加载为真,展开所有节点并折叠它们。

展开和折叠是必要的,因为我正在处理用户交互树的叶节点。

有没有办法通过 来实现?按需加载设置为假?

最佳答案

<!DOCTYPE html>
<html>
  <head>
    <base href="http://demos.telerik.com/kendo-ui/treeview/local-data-binding">
    <style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
    <title></title>
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.1028/styles/kendo.common-material.min.css" />
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.1028/styles/kendo.material.min.css" />
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.1028/styles/kendo.material.mobile.min.css" />

    <script src="//kendo.cdn.telerik.com/2016.3.1028/js/jquery.min.js"></script>
    <script src="//kendo.cdn.telerik.com/2016.3.1028/js/kendo.all.min.js"></script>
  </head>
  <body>
    <div id="example">

      <div class="demo-section k-content">
        <h4>Inline data (default settings)</h4>
        <div id="treeview-left"></div>
      </div>


      <script>
        var inlineDefault = new kendo.data.HierarchicalDataSource({                      
          data: [{

            "Name": "Test",
            "enabled": true,
            "text": "Test",
            "id": "Test",
            "Description": null,
            "Key": null,
            "items": [{
              "Name": "Workspace",
              "enabled": true,
              "text": "Workspace",
              "id": "Workspace",
              "Description": null,
              "Key": null,
              "items": [],
              "checked": true,
              "expanded": true
            },
                      {
                        "Name": "Deploy",
                        "enabled": true,
                        "text": "Deploy",
                        "id": "Deploy",
                        "Description": null,
                        "Key": null,
                        "items": [{
                          "Name": "Test.Deploy.Application",
                          "enabled": true,
                          "text": "Application",
                          "id": "Test.Deploy.Application",
                          "Description": "",
                          "Key": "Test.Deploy.Application",
                          "items": [],
                          "checked": false,
                          "expanded": true
                        },
                                  {
                                    "Name": "Test.Deploy.Visualization",
                                    "enabled": true,
                                    "text": "Visualization",
                                    "id": "Test.Deploy.Visualization",
                                    "Description": "",
                                    "Key": "Test.Deploy.Visualization",
                                    "items": [],
                                    "checked": true,
                                    "expanded": true
                                  },
                                  {
                                    "Name": "Test.Deploy.Application Workspace",
                                    "enabled": true,
                                    "text": "Application Workspace",
                                    "id": "Test.Deploy.Application Workspace",
                                    "Description": "",
                                    "Key": "Test.Deploy.Application Workspace",
                                    "items": [],
                                    "checked": false,
                                    "expanded": true
                                  }],
                        "checked": null,
                        "expanded": true
                      }],
            "checked": null,
            "expanded": true
          }]

        });

        $("#treeview-left").kendoTreeView({
          dataSource: inlineDefault,
          checkboxes: {
            checkChildren: true,
          },
          loanOnDemant:false,
        });


      </script>
    </div>


  </body>
</html>

它为我工作!
For more details

关于javascript - Kendo UI Treeview - 绑定(bind)到本地数据时更新复选框状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45800926/

相关文章:

kendo-ui - 打印中的 Kendo Graph 问题

jquery - 如何更改已过滤的单元格中的过滤器颜色

javascript - NestJS createParamDecorator 返回未定义

javascript - jQuery、多个输入和 onBlur

html - 无法找出未应用复选框样式的原因

javascript - 轻松限制选中的复选框 jquery ui

html - CSS 复选框样式在其他页面上表现不同

javascript - 如何捕获kendo UI 自动完成组件的DataValueField?

javascript - 为什么我的 php echo 不起作用?

javascript - RxJS 中按特定时间量分隔可观察值