Tree View List Show Intermediate State

2 posts, 0 answers
  1. Alex
    Alex avatar
    10 posts
    Member since:
    Jun 2018

    Posted 04 Sep 2019 Link to this post

    Hi

    I have a tree view list which connects to a datasource and saves which nodes have been checked into a grid. When I load the page again I want to be able to take what is in the grid and check the corresponding nodes again. This is the code I have wrote so far, when the page loads it reads the datatable and checks the parent and child nodes which match the data. However it is checking all of the child nodes even though not all of the nodes appear in the datatable, how can I check the parent node in an intermediate state?

                    DataTable Branches = new DataTable();
                    DataSourceSelectArguments args = new DataSourceSelectArguments();
                    DataView view = (DataView)sdsCampaignBranch.Select(args);
                    if (view != null)
                        Branches = view.ToTable();

                    tvBranches.DataBind();

                    foreach (RadTreeNode parent in tvBranches.Nodes)
                    {
                        foreach (RadTreeNode child in parent.Nodes)
                        {
                            for (int j = 0; j < Branches.Rows.Count; j++)
                            {
                                if (parent.Attributes["ItemValue"].ToString() == Branches.Rows[j][0].ToString().Trim())
                                {
                                    parent.Checked = true;
                                }

                                if (child.Attributes["ItemValue"].ToString() == Branches.Rows[j][1].ToString().Trim())
                                {
                                    child.Checked = true;   
                                }          
                            }
                        }
                    }

  2. Peter Milchev
    Admin
    Peter Milchev avatar
    656 posts

    Posted 09 Sep 2019 Link to this post

    Hello Alex,

    When the TriStateCheckBoxes="true" property is present in the TreeView configuration, then checking the child node would automatically set the parent node's state to Indeterminate. This state is then available through the CheckState read-only property of the Node.

    With that said, if you need to set Indeterminate state of a node, you just need to have at least one of its child nodes to be checked and the TreeView will mark it Indeterminate itself.

    Regards,
    Peter Milchev
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top