Issue with getting correct Checked value on NodeCheck

2 posts, 0 answers
  1. Fred Koehlmann
    Fred Koehlmann avatar
    7 posts
    Member since:
    Feb 2008

    Posted 08 Sep 2009 Link to this post

    The treeview has two to three levels of nodes with checkboxes (CheckBoxes="True" TriStateCheckBoxes="True" CheckChildNodes="True"). The intention is to allow the user to select one node out of all of them. Upon selecting, all nodes except the one that they have selected are disabled. Upon unchecking the previously checked node, all the nodes within the tree are re-enabled. For some reason this only works as long as the user selects any of the most child nodes within the tree. If an intermediate/parent or root node is selected, it can not be de-selected. Upon debugging I see that I am always getting a value of "e.Node.Checked=true" upon NodeChecked! However the client side code does indicate correctly that the state of the checkbox has changed.

    <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?

  2. Yana
    Admin
    Yana avatar
    4985 posts

    Posted 09 Sep 2009 Link to this post

    Hello Fred,

    I tried to replicate the issue with the provided code but to no avail. Could you please isolate the problem in a small runnable project and send it to us, so we could test it? You should open a support ticket and attach it there. Thanks

    Best regards,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top