<telerik:RadTreeView ID="TreeViewRoles" runat="server" CheckBoxes="True" TriStateCheckBoxes="True" CheckChildNodes="True" Skin="WebBlue" OnClientNodeChecked="onNodeClicked" OnNodeCheck="TreeViewRoles_NodeCheck" Height="290px"></telerik:RadTreeView>
The following code works just fine if the node is a child most node:
Protected Sub TreeViewRoles_NodeCheck(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles TreeViewRoles.NodeCheck
If e.Node.Checkable Then
Dim checked As Boolean = e.Node.Checked
'Assuming that the tri-state was partly an issue this work around was tried but with no effect…
Dim checkedState As Telerik.Web.UI.TreeNodeCheckState = e.Node.CheckState
checked = IIf(checkedState = Telerik.Web.UI.TreeNodeCheckState.Checked, True, False)
Dim NodeUniqueID As String = e.Node.Attributes("UniqueID").ToString()
For Each rootNode As Telerik.Web.UI.RadTreeNode In TreeViewRoles.Nodes
EnableNode(rootNode, Not checked, NodeUniqueID)
Next
End If
End Sub
Private Sub EnableNode(ByVal node As Telerik.Web.UI.RadTreeNode, ByVal enable As Boolean, ByVal checkedNodeUniqueID As String)
If node.Nodes.Count > 0 Then
For Each childNode As Telerik.Web.UI.RadTreeNode In node.Nodes
EnableNode(childNode, enable, checkedNodeUniqueID)
Next
End If
If node.Attributes("UniqueID").ToString() <> checkedNodeUniqueID Then node.Enabled = enable
Debug.Print("Node:" + node.Attributes("UniqueID").ToString() + " Checked: " + node.Checked.ToString() + " / " + PadText(node.CheckState.ToString() + " NodeName: " + node.Text)
End Sub
The following client side code shows that the checkbox's state has changed:
function onNodeClicked(sender, args)
{
var node = args.get_node();
alert("Level:" + node.get_attributes().getAttribute("NodeLevel") + "\nChecked:" + node.get_checked() + "\n");
}
Is there something that I am missing with respect to tri-state checkboxes in the nodes? Why am I not getting the checked=false when a user unchecks it?