unable to retrieve checked nodes in tree view

4 posts, 1 answers
  1. Vinay
    Vinay avatar
    8 posts
    Member since:
    Jan 2010

    Posted 25 Nov 2010 Link to this post

    Hi I have a tree view with checkboxes on each node. I have written some javascript to check relevant nodes when parent and child nodes on the tree view.

    When i try to iterate through nodes on server side ie

    foreach (RadTreeNode node in RadTree.CheckedNodes)
    {
        string value = node.Text.ToString();
    }

    the value of CheckedNodes.Count = 0

    Here is what I do with the javascript to check nodes
    var node = args.get_node();
    var parentnode = node.get_parent();
    if (!node.get_checked()) {
        var childNodes = node._getChildren();
        var nodeArray = childNodes.toArray();
        for (var i = 0; i < nodeArray.length; i++) {
            nodeArray[i].set_checked(true);
            var GrandChildren = nodeArray[i]._getChildren();
            var nodeGCArray = GrandChildren.toArray();
            for (var x = 0; x < nodeGCArray.length; x++) {
                nodeGCArray[x].set_checked(true);
            }
        }

    please help ..

  2. Answer
    Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 25 Nov 2010 Link to this post

    Hello Vinay,

    As i see you are using your private function to check all of the child items when a parent item is checked. My suggestion is to use the property CheckChildNodes, when set to true it will automatically check all child items.After that it shouldn't be a problem to get the count of the checked items on the server-side.


    All the best,
    Dimitar Terziev
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Vinay
    Vinay avatar
    8 posts
    Member since:
    Jan 2010

    Posted 25 Nov 2010 Link to this post

    <td><telerik:RadTreeView ID="RadTree" runat="server" CheckBoxes="true" CheckChildNodes="true" OnClientNodeChecked="beforeClientCheck"></telerik:RadTreeView></td><td><td><telerik:RadTreeView ID="CloneRadTree" runat="server"></telerik:RadTreeView></td></td>

    I have done this in the aspx page.

    There does not seem to be a difference. Perhaps it would help to know that I am populating the Radtree using XML generated from a webservice. I do have a custom Attribute called Clone in node element.

    I have also attached an image whilst debugging that shows the value of a few variables, such as checked state etc. Note  that checkable value in the node is True but the status is unchecked. Though I have checked it in the aspx page.
  4. Vinay
    Vinay avatar
    8 posts
    Member since:
    Jan 2010

    Posted 25 Nov 2010 Link to this post

    Sorry for wasting your time. It was because i did not check the IsPostBack == false on the Page_load method. Works fine ! My apologies.
Back to Top