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

$find on a TreeView returns null.

1 Answer 80 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 22 Mar 2013, 02:08 AM

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.

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 22 Mar 2013, 04:19 PM
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.


Regards,
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.
Tags
TreeView
Asked by
David
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or