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

CheckChildNodes and OnClientNodeChecked

2 Answers 134 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 28 Aug 2008, 04:42 PM
I am looking at the sample http://demos.telerik.com/ASPNET/Prometheus/TreeView/Examples/Functionality/CheckBoxes/DefaultCS.aspx
and it says that
"This example also demonstrates  the use of the OnClientNodeChecked event, which allow fine-tuning of the RadTreeView behavior. This event is used to check/uncheck all child nodes if the parent node is checked/unchecked."

But this sample does not use the OnClientNodeChecked event. Instead it uses the CheckChildNodes property.

But I am actually looking for the Javascript to "uncheck" all of child nodes if it is unchecked (it sounds like the way the example used to work). But not to auto-check all child nodes if checked. Does this example still exist?

Thanks!

2 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 01 Sep 2008, 02:26 PM
Hi Jay,

You are right - in that example we do not use the OnClientNodeChecked event anymore.

You can subscribe to the OnClientNodeChecking client-side event and define its event handler as follows:

<script type="text/javascript"
function OnClientNodeCheckingHandler(sender, eventArgs) 
    var node = eventArgs.get_node(); 
 
    if (node.get_checked()) 
    { 
        uncheckAllChildren(node); 
    } 
 
function uncheckAllChildren(node) 
    var nodes = node.get_nodes(); 
     
    for (var i = 0; i < nodes.get_count(); i++) 
    { 
        var child = nodes.getNode(i); 
        child.uncheck(); 
        uncheckAllChildren(child); 
    }    
</script>  

I hope this helps.

Best wishes,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jay
Top achievements
Rank 1
answered on 01 Sep 2008, 06:09 PM
Perfect! Thanks!
Tags
TreeView
Asked by
Jay
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Jay
Top achievements
Rank 1
Share this question
or