2017-08-21 40 views
0

更新复选框状态我有一个JavaScript对象与项目数组定义层级。当我创建一个kendoTreeView部件与此数据,loadOnDemand设置为假,本来应该是不确定的复选框,显示为未选中状态。剑道UI树视图 - 当绑定到本地数据

我所做的解决这个问题的方法是将loadOnDemand设置为true,展开所有节点并将其折叠。

的展开和折叠是必要的,因为我在用户交互树的叶节点上工作。

有没有办法实现这个loadOnDemand设置为false?

回答

0
<!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