This is a migrated thread and some comments may be shown as answers.

Child node doesn't be checked unless expend it or check twice

2 Answers 74 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
JC Software Services, Inc.
Top achievements
Rank 1
JC Software Services, Inc. asked on 31 Aug 2015, 05:04 AM

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);
        }
    )
)

2 Answers, 1 is accepted

Sort by
0
JC Software Services, Inc.
Top achievements
Rank 1
answered on 31 Aug 2015, 05:45 AM

It is something wrong in my post.

  1. I mean expand not expend.
  2. If I check the parent node after expand the child node, it still not check the child node too.
0
Daniel
Telerik team
answered on 02 Sep 2015, 08:01 AM
Hello,

The described behavior indicates that the initial state is invalid - the parent node is checked but not all of its children are checked. If this is the case then you should change the initial parent state to false or make all children checked.

Regards,
Daniel
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TreeView
Asked by
JC Software Services, Inc.
Top achievements
Rank 1
Answers by
JC Software Services, Inc.
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or