treeview checkstate always Unchecked

2 posts, 0 answers
  1. Mohan
    Mohan avatar
    22 posts
    Member since:
    Apr 2009

    Posted 22 Sep 2009 Link to this post

    I have  following radtreeview  defined

     <telerik:RadTreeView ID="tvGroups"  runat="server" TriStateCheckBoxes="true" CheckBoxes="true" OnClientNodeChecked="nodeChecked" >
            </telerik:RadTreeView>


    On the server I have the following code.
     foreach (RadTreeNode node in tvGroups.CheckedNodes)
                {
                    Trace.Warn("Value: " + node.Value + ":: Text: " + node.Text +" :: Checked: " + node.Checked.ToString() + ":: CheckedState: " + node.CheckState.ToString());
                    if (node.CheckState == TreeNodeCheckState.Checked)
                    {
                          //Do something only if the Checkbox is checked.
                          //Ignore if its indeteminate.
                    }
                }

    The problem is that the CheckState is always Unchecked. I am not sure what I am doing wrong.

    THanks



  2. Mohan
    Mohan avatar
    22 posts
    Member since:
    Apr 2009

    Posted 23 Sep 2009 Link to this post

    after some more testing, I want to some of my findings,

    I have the following data in the treeview
    Root
       -     Node1
                - Subnode 11
       -     Node2
       -     Node3
       -     Node4
                -subnode41


    All the nodes are Checkable. I have not enabled CheckChildNodes.

    I am also setting the parent node value to indeterminant on the client side using the code below.
    function nodeChecked(sender, args)  
    {  
        var node = args.get_node();  
        var parent = node.get_parent();  
        if(parent != sender)  
        {  
            if(node.get_checked() == true)  
            {  
                //sender._checkChildNodes = false;
                //parent.set_checked(true);
                parent.get_checkBoxElement().className = "rtIndeterminate";
               //sender._checkChildNodes = true;  
            }  
            else
            {  
                var isChildChecked = false;  
                for(var i=0;i<parent.get_nodes().get_count();i++)  
                {  
                    if(parent.get_nodes().getNode(i).get_checked())  
                        isChildChecked = true;  
                }  
                  
                if(!isChildChecked)  
                    parent.set_checked(false);  
            }  
        }
    }


    The issue I am having is that if I select Node4 and submit then in the CheckedNodes collection, I have Root node and the Node4. The Checked value in both the nodes are true but the CheckState value is Unchecked. The CheckState value should be indeterminate for
    the Root node and Checked for Node4

    If I select  subnode41 then the CheckedNodes collection has the Root, Node4 and the subnode41 nodes. The Checked value is true for all 3 of the nodes and the CheckState value is Indeterminate for the Root node, Checked for Node4 and subnode41.  The CheckState value should be Indeterminate for the Root and Node4  nodes and Checked for the subnode41.

    I am not sure why the CheckState value is not behaving as expected.


Back to Top