This is a migrated thread and some comments may be shown as answers.

Checkbox Hide UncheckAllNodes

2 Answers 74 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 2
Alex asked on 24 Feb 2011, 05:31 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Tsenkov
Telerik team
answered on 01 Mar 2011, 12:37 PM
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!
0
Alex
Top achievements
Rank 2
answered on 02 Mar 2011, 08:19 PM
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!
Tags
TreeView
Asked by
Alex
Top achievements
Rank 2
Answers by
Nikolay Tsenkov
Telerik team
Alex
Top achievements
Rank 2
Share this question
or