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

Why can disabled node can be unchecked?

2 Answers 116 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ed Staffin
Top achievements
Rank 1
Ed Staffin asked on 21 Mar 2011, 02:46 PM
Hi, I have a treeview as follows:
<telerik:RadTreeView ID="tvCC" Runat="server" CheckBoxes="True" 
        Skin="Vista" TriStateCheckBoxes="True" CheckChildNodes="True" BorderStyle="Solid"
        BorderColor="Black" BorderWidth="1"  Height="350px" Width="400px" >
</telerik:RadTreeView>          

In the code behind I disable a child node of a root node.
This prevents the user from checking or unchecking the specific node.
This is good. However, if I  uncheck or check the parent node the child still get's toggled even though it's disabled.
Anyway to prevent this client side?
Thanks ... Ed

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Mar 2011, 06:59 AM
Hello Ed,

You can set the 'Checkable' property of RadTreeView node as false when disabling that particular node which in turn disables to select the CheckBox of the child node.

C#:
RadTreeNode node = tvCC.FindNodeByText("Brisbane");//find the node
node.Enabled = false;
node.Checkable = false;

Thanks,
Princy.
0
Ed Staffin
Top achievements
Rank 1
answered on 22 Mar 2011, 01:44 PM
Hi thanks for the reply, but that doesn't work.
They still need to be able to click on the parent.

Here's what I did as a work around. Cludgy, but works.
function DoOnClientNodeChecked(sender, eventArgs) 

{
   // basically this function serves to protect disabled nodes.
   // the problem comes in when a parent node of a disabled child node is unchecked.
   // in this case the control unchecks all child nodes even if they are disabled.
   // so, this forces disabled nodes back.
   var oNode;
   var i;
   var oAllNodes = eventArgs.get_node().get_allNodes();
   for (i = 0; i < oAllNodes.length; i++)
   {
       oNode = oAllNodes[i];
       if (!oNode.get_enabled())
           oNode.check();
   }
}

Thanks ... Ed

Tags
TreeView
Asked by
Ed Staffin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ed Staffin
Top achievements
Rank 1
Share this question
or