$find on a TreeView returns null.

2 posts, 0 answers
  1. David
    David avatar
    48 posts
    Member since:
    Nov 2012

    Posted 21 Mar 2013 Link to this post

    I'm trying to set some tree nodes from the client side once the page loads using the code below:

    var tree = $find(clientId);
    var allTreeNodes = tree.get_allNodes();

    However I get the error below when I try to run it in $(document).ready or $(window).ready.

    Microsoft JScript runtime error: Unable to get value of the property 'get_allNodes': object is null or undefined.

    So basically it doesn't find the tree.  I tested it with jQuery using $("#" + clientId).length and it returns 1 so it exists.

    The only time it works is in the pageLoad() which I think is an asp.net ajax method.   Can someone explain why this is the case?

    Thanks, Dave.

  2. Boyan Dimitrov
    Boyan Dimitrov avatar
    1966 posts

    Posted 22 Mar 2013 Link to this post

    Hello Dave,

    The document ready state is a little bit early in the page life cycle and the client objects are not yet initialized. Therefore the safest way would be to use the pageLoad event when the RadTreeView client-side object is initialized and ready to be accessed and used.

    Boyan Dimitrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top