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

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

2 Answers 167 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 04 Mar 2013, 06:24 PM
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 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 05 Mar 2013, 05:42 PM
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.
0
David
Top achievements
Rank 1
answered on 19 Mar 2013, 04:39 PM
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.
Tags
TreeView
Asked by
David
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
David
Top achievements
Rank 1
Share this question
or