Uncheck "All" when child is un-checked OR Check "All" when you check all children?

3 posts, 0 answers
  1. David
    David avatar
    48 posts
    Member since:
    Nov 2012

    Posted 04 Mar 2013 Link to this post

    Hi,

    When I check the root "All" nodes, all the children get checked as expected.

    1. However, when I un-check one of the children,  I would expect  the root "All" node to be unchecked but it stays checked.
    2. Also, on a cleared treeview, when I go through and check all the chidren, I would like the "All" to be automatically checked.

    Are there options to do this or does all of this take custom script?

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 05 Mar 2013 Link to this post

    Hello,

    Thank you for contacting Telerik Support.

    I would like to clarify that the provided custom solution will work if your RadTreeView has one "All" root node. Please let us know if this is not what you are looking for and how exactly your scenario is different.
    Regarding your first question - you may uncheck that "All" node if one of its child nodes has been unchecked as shown in the code snippet below:
    //markup code
    <telerik:RadTreeView ID="RadTreeView1" runat="server" CheckBoxes="true" OnNodeCheck="RadTreeView1_NodeCheck">
        <Nodes>
            <telerik:RadTreeNode Text="All">
                <Nodes>
                  .....
                </Nodes>
            </telerik:RadTreeNode>
        </Nodes>
    </telerik:RadTreeView>
    //code behind
    protected void RadTreeView1_NodeCheck(object sender, RadTreeNodeEventArgs e)
       {
           if (e.Node.Level != 0 && e.Node.CheckState == false)
           {
               RadTreeView1.FindNodeByText("All").Checked = false;
           }
       }

    Regarding your second question - this solution assumes that the root node of your RadTreeView control is "All" and has only one sub level child nodes.
    //code behind
    if (RadTreeView1.CheckedNodes.Count == RadTreeView1.Nodes.Count - 1)
            {
                RadTreeView1.FindNodeByText("All").Checked = true;
            }


    Kind regards,
    Boyan Dimitrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David
    David avatar
    48 posts
    Member since:
    Nov 2012

    Posted 19 Mar 2013 Link to this post

    Actually, I'm finally getting back to this issue.  I was referring to doing this on the client and my treeview has multiple levels.

    If I come up with a solution I'll post it here.
Back to Top