Thanks for the addition of the CheckBoxes. Here is an easy method to access the value using templates
This is a change to the example code.
1. change the template as follows...
In addition, you an auto check the box on node click as follows
Enjoy.
This is a change to the example code.
1. change the template as follows...
<
script
id
=
"treeview-checkbox-template"
type
=
"text/kendo-ui-template"
>
<
input
type
=
"checkbox"
name
=
"checkedFiles[#= item.id #]"
value
=
"#= item.id #"
/>
</
script
>
2. You can access the value as follows... function showSerializedData() {
var chkBox = $("#treeview input")
var serializedData = chkBox.serialize()
.replace(/%5B/g, "[")
.replace(/%5D/g, "]")
.replace(/&/g, "&");
//get the value...
var value = chkBox.val();
//do something with it
$("#checked-nodes").html(serializedData);
}
In addition, you an auto check the box on node click as follows
function onSelect(e) {
var checkboxes = $(e.node).find(":checkbox");
if(checkboxes.length > 0)
$(checkboxes[0]).prop('checked','checked')
//HINT: you can get the node text this way as well
var nodeText = e.node.outerText;
}
Enjoy.