Hi,
I am using kendo treeview with checkboxes in ASP .Net MVC. The datasource for the treeview is a list of item and want some of them to be selected on loading the treeview and then I want to pass the newly selected items to the controller. I can achieve each one of the two separately(with a line of code for each functionality), but they seem to be mutually exclusive.
This is my code for the view:
@(Html.Kendo().TreeView()
.Name("PrescriptionProductInstructions")
.DataTextField("Name")
.Checkboxes(x => x.CheckChildren(true))
.CheckboxTemplate("<input type='checkbox' name='checkedFiles[#= item.id #]' value='#= item.id #' #if(item.IsChecked){# checked #}#/>")
.Events(events => events.DataBound("onDataBound"))
.Checkboxes(x => x.Name("PrescriptionProductInstructions"))
.DataSource(source => source.Read(read => read.Action("GetInstructions", "Note", new { productId = Model.ProductId, personId = Model.PersonId }))))
<script>
function onDataBound() {
$("#PrescriptionProductInstructions").data("kendoTreeView").expand(".k-item");
}
</script>
The first bold line of code helps me pre-select some item when loading the tree and the second line of code helps me pass the list of ids of the selected items.
My question is whether I can have both functionalities as the same time? If yes, how?
Thanks in advance.
Regards,
Dayana Hadzhipetrova