2016-01-14 35 views
0

我無法在ken​​do treedatasource中顯示值。這是Kendo TreeDataSourc的有效JSON嗎?這是一個適用於Kendo Datasource的有效JSON嗎?

"[{\"fields\": {\"tgtWeight\": 0.0, \"hasChildnode\": true, \"parent\": null, \"currWeight\": 0.0, \"classificationNameNode\": null, \"SSM\": \"ssm4\", \"ext_model_id\": 4}, \"model\": \"equity.usersecurityselectionmodel\", \"pk\": 14}]" 

這是劍道的一面。

var dataSource = new kendo.data.TreeListDataSource({ 
     transport: { 
      read: { 
       url: "../getModelTargetWeights?id="+id, 
       dataType: "json" 
      } 
     }, 
     schema: { 
      model: { 
       id: "pk", 
       parentId: "parent", 
       fields: { 
          fields: { field: "fields"}, 
          tgtWeight: {field: "tgtWeight", type :"number"} 
       } 
       } 
      } 
    }); 

    $("#treeList").kendoTreeList({ 
     dataSource: dataSource, 
     editable: true, 
     height: 540 

回答

2

你的數據源的模式應該是這樣的:

dataSource: { 
    schema: { 
     model: { 
      id: "pk", 
      parentId: "parent", 
      fields: { 
       parent: { nullable: true} 
      } 
     } 
    } 
} 

JSON陣列中的每個元素應該包含hasChildren成員

更新:JSON陣列本身:

[{\"tgtWeight\": 0.0, \"hasChildren\": true, \"parent\": null, \"currWeight\": 0.0, \"classificationNameNode\": null, \"SSM\": \"ssm4\", \"ext_model_id\": 4, \"model\": \"equity.usersecurityselectionmodel\", \"pk\": 14}] 

例如:http://dojo.telerik.com/uJoLo

+0

Gene..thanks for the response.the haschildNode can be into the hasChildren member。 PareintId是父項。我不確定的是實際的字符串。它看起來是正確的,但Kendo無法解析它。 – Axwack

+0

@Axwack我更新了回答 –

+0

Gene ...非常感謝。你達人! – Axwack