mercredi 19 octobre 2016

Why treeview checkbox doesn't appear when using template?

The current problem is that the checkbox doesn't appear in my kendo treeview. The reason of using the template is i wanted to define the checkbox name where it is more easily to handle the checked event but i'm not sure the format of the template is correct.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Kendo UI Snippet</title>

    <link rel="stylesheet" href="http://ift.tt/2dZXwz7"/>
    <link rel="stylesheet" href="http://ift.tt/2dm6XLu"/>
    <link rel="stylesheet" href="http://ift.tt/2e6NLmC"/>
    <link rel="stylesheet" href="http://ift.tt/2dm62e4"/>

    <script src="http://ift.tt/297PIH7"></script>
    <script src="http://ift.tt/2dyGzxD"></script>
</head>
<body>
  
<div id="treeview" data-role="treeview" data-template="treeviewtemplate" data-text-field="text" data-checkboxes='{"checkChildren": true,template:checkboxtemplate}' data-value-field="value"></div>
  
  <script id="treeviewtemplate" type="text/kendo-ui-template">
     #= item.text #
  </script>
  
  <script type="text/javascript">
     function checkboxtemplate(e){
     return "#if(!item.hasChildren){#<input type='hidden' parent_id='#=item.parent_id#' d_text='#=item.value#' /><input type='checkbox' name='checkedFiles[#= item.value #]' value='true' />#}else{#<input type='checkbox' parent_id='#=item.parent_id#' d_text='#=item.value#' /> #}#"
     }
  </script>
  
  <script>
$("#treeview").kendoTreeView({
  dataSource: {
  data: [
    { id      : 5,
     parent_id: 0,
     text    : "General - Primary Probe",
     value    : "General - Primary Probe",
     expanded : true,
     items    : [
       { id: 51, parent_id: 5, text: "Agent Running Mode",value:"priProbeARM"},
       { id: 52, parent_id: 5, text: "Agent Version",value:"priProbeAV"},
       { id: 53, parent_id: 5, text: "Master/Slave Mode",value:"priProbeMSM"},
       { id: 54, parent_id: 5, text: "Manufacturer",value:"priProbeManu"},
       { id: 55, parent_id: 5, text: "Model",value:"priProbeModel"},
       { id: 56, parent_id: 5, text: "Software Version",value:"priProbeSV"}
     ]}]
  }
});
</script>
</body>
</html>



Aucun commentaire:

Enregistrer un commentaire