I use TreeViewBuilder.Items to build tree view.
Child nodes doesn't be checked when I check parent node without expend nodes, but if I check the parent node again(without expend too), child nodes will be checked.
@using Kendo.Mvc.UI.Fluent;
@model List<
AuthViewModel
>
@functions
{
public static void ShowTree(TreeViewItemFactory helper, IEnumerable<
AuthViewModel
> nodes)
{
foreach (var node in nodes)
{
helper.Add()
.Id(node.ID)
.Text(node.NAME)
.Checked(node.IsChecked)
.Expanded(false)
.Items(items =>
{
if (node.Childs.Count() > 0)
{
ShowTree(items, node.Childs);
}
});
}
}
}
@(Html.Kendo().TreeView()
.Name("authTree")
.Checkboxes(checkboxes => checkboxes
.Name("checkedFiles")
.CheckChildren(true)
)
.Items(root =>
{
ShowTree(root, Model);
}
)
)