Checkbox Hide UncheckAllNodes

3 posts, 1 answers
  1. Alex
    Alex avatar
    31 posts
    Member since:
    Jun 2009

    Posted 24 Feb 2011 Link to this post

    I have a RadTreeView set up so that the lowest level of the tree has a check box. It has many nodes so I have implemented the Page Methods functionality.  I am trying to decrease the level of clicks by using the UncheckAllNodes() method on the tree. On tree load I have a javascript function that will hide the original node and I created a custom RadTreeNodeData class that has an object ShowCheckBox and Checked objects. When I call the UncheckAllNodes, I need it to be on the lowest level, instead what I'm getting is all nodes unchecked (expected), but the check boxes are showing up for the non-lowest level nodes. Is there a function I could call that will re-hide the check boxes, or a function that will un-check nodes that are checked? That way it won't affect the style I've applied to the nodes above?

    function TreeViewLoad() {
        var treeView = $find("<%=TreeView.ClientID%>");
        if (treeView != null) {
            var node = treeView.get_nodes().getNode(0); //get the first node
            node.get_checkBoxElement().style.display = "none"; // hide the CheckBox
        }
    }

    function OnClientNodeDataBoundHandler(sender, e) {
        var node = e.get_node();
        if (e.get_dataItem().ShowCheckBox) {
            node.set_checked(e.get_dataItem().Checked);
        }
        else {
            node.get_checkBoxElement().style.display = "none"; // hide the CheckBox
        }
    }
  2. Answer
    Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 01 Mar 2011 Link to this post

    Hi Alex,

    You can use the server-node's property Checkable for removing the checkboxes of the nodes that shouldn't have it (in this case - "node.Checkable = false;").


    Regards,
    Nikolay Tsenkov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. Alex
    Alex avatar
    31 posts
    Member since:
    Jun 2009

    Posted 02 Mar 2011 Link to this post

    That worked, since I'm using node data and not just the node class, I had to declare a "Checkable" so it would work. Of course it took away the checkboxElement since there isn't one, but that works fine for me. Thanks!
Back to Top