Unchecking a RadTreeNode with jQuery

3 posts, 0 answers
  1. Derek Hunziker
    Derek Hunziker avatar
    62 posts
    Member since:
    Sep 2008

    Posted 03 Jun 2009 Link to this post

    Hi There,

    I have a RadTreeView (Q2 2008) inside of an UpdatePanel.  Also inside the UpdatePanel is a button that deletes all the "checked" nodes.

    I'm using jQuery to extend the functionality so that all the child nodes get checked and unchecked with the parent node.  If one of the child nodes is unchecked, the parent checkbox is unchecked too (but not the prev and next child checkboxes).  I was able to achieve this using the following code:

    function pageLoad() { 
            $('.rtChk').bind('click'function() { 
                // Check/uncheck child checkboxes 
                var parentLi = $(this).parents('.rtLI:first'); 
                if ($(this).is(':checked')) 
                // Uncheck parent checkbox on uncheck 
                var grandParentLi = $(this).parents('.rtLI:first').parents('.rtLI:first'); 
                if ($(this).is(':checked') == false

    This code is working out great and when I uncheck one of the child nodes, the parent appears to be uncheck... however, when I click the button to delete all checked nodes, the parent still gets deleted.  I'm thinking that somewhere along the way, the jQuery "uncheck" isn't registering with my asyncronos postback?

    I have a RadScriptManager on the page and I've tried registering the script using Page.RegisterStartupScript... but it still doesn't work.

    Any suggestions?

  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 04 Jun 2009 Link to this post

    Hello Derek Hunziker,

    You should use the API of RadTreeView in order to check the nodes. The latter correctly updates the internal state of the treeview. Just checking the checkboxes will not properly persist the checked state of the nodes after postback.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Derek Hunziker
    Derek Hunziker avatar
    62 posts
    Member since:
    Sep 2008

    Posted 04 Jun 2009 Link to this post

    Well that was easy... I should have used the API from the get go (much easier than jQuery)

    Here's the code I used in case anyone is doing the same.  

    function ClientNodeChecking(sender, eventArgs) { 
            var node = eventArgs.get_node(); 
            // Check/uncheck all children 
            for (var i = 0; i < node.get_nodes().get_count(); i++) { 
                var child = node.get_nodes().getNode(i); 
                if (node.get_checked()) 
            if (node.get_checked()) { 
                var parent = node.get_parent(); 
                // Make sure the node we're checking isn't the root node 
                if (node.get_parent() != node.get_treeView()) 

Back to Top