When I try to add checkboxes to the TreeView,devtools int he browser show I am getting "Invalid Template"
This works (but no checkboxes). But if I uncomment the ".Checkboxes part, it throws error. I have tried many variants, including just ".Checkboxes(true)".
<script id="UserDetailsTemplate" type="text/kendo-tmpl">
@*@Html.Kendo().TextBox().Value("foo #= User_Login#").Name("yoda_#=User_Login#")*@
@(Html.Kendo()
.TabStrip()
.Name("userTabStrip_#=Person_ID#")
.SelectedIndex(0)
.Items((items) =>
{
items.Add()
.Text("Contact Info");
items.Add()
.Text("Permissions")
.Content(obj => Html.Kendo()
.TreeView()
.DataTextField("Name")
.Name("userModulePermissions#=Person_ID#")
//.Checkboxes(cbxConfig => cbxConfig.Enabled(true)
// .CheckChildren(true)
// .Name("checkedNodes"))
.DataSource(d => d.Read("PermissionsTree_Read",
"SettingsUsers"))
.ToClientTemplate());
items.Add()
.Text("Group Membership");
})
.ToClientTemplate()
)
</script>
Here is the action the provides the tree data:
public JsonResult PermissionsTree_Read(long? id)
{
var moduleId = id;
var tracDB = new TRACEntities();
// because modules & permissions are not same thing, we have to distinguish what "level" we are at in the tree
// modules are root level, permissions (sub_sections) are next (leaf) level
if (moduleId == null)
{
var result = GetOrgModules()
.Select(m => new {
id = m.Module_Type_ID,
Name = m.Module_Type_Name,
hasChildren = GetUserModuleSubsectionPermissions(m.Module_Type_ID).Any(),
@checked = false
});
return Json(result,
JsonRequestBehavior.AllowGet);
}
else
{
var result = GetUserModuleSubsectionPermissions((long) moduleId)
.Select(p => new {
id = p.Sub_Section_Type_Id,
Name = p.Sub_Section_Type_Desc,
hasChildren = false, //always leaves
//@checked = false //I have tried with and without this line -- it was just a guess that this was needed
});
return Json(result,
JsonRequestBehavior.AllowGet);
}
}