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

Radtreeview problem with client-side find

1 Answer 69 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 02 Feb 2009, 07:27 PM
Hello:

I've been scratching my head for two days for trying to migrating to the new ajax version of radtreeview.
I have read your tutorials and have tried almost everything mentioned from registering the telerik assembly to creating a radtree with radajaxmanager. The sample program compiles correctly but when I tried to access a tree using javascript (within radcodeblock) using:
var treeView = $find("RadTreeView2");
...
...
<telerik:RadTreeNode runat="server" Text="Products" ExpandMode="ClientSide">
               <Nodes>
                   <telerik:RadTreeNode runat="server" Text="Books" ExpandMode="ClientSide">
                   <Nodes>
                       <telerik:RadTreeNode runat="server" Text="Fiction"></telerik:RadTreeNode>
                       <telerik:RadTreeNode runat="server" Text="Non-Fiction"></telerik:RadTreeNode>
                       <telerik:RadTreeNode runat="server" Text="Biography"></telerik:RadTreeNode>
                       <telerik:RadTreeNode runat="server" Text="Humor"></telerik:RadTreeNode>
                   </Nodes>
                   </telerik:RadTreeNode>
               </Nodes>
           </telerik:RadTreeNode>
           </Nodes>
       </telerik:RadTreeView>
...



After debugging, it shows that the find did nothing and treeView is null.
Is there any explaination to this?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Feb 2009, 07:29 AM

Hi Ken,

 

I am not sure about what is happening at your side. How are you calling the function to getting the RadTreeView client side object? I tried getting the RadTreeView from a button click event handler and it is working for me. Check the below code and see whether it is working fine for you.

Here's the ASPX:

<script type="text/javascript"
function gettreeview() 
    var treeView = $find("RadTreeView2");   //get the client side object  
</script> 
</telerik:RadCodeBlock> 
<telerik:RadTreeView ID="RadTreeView2" Runat="server"
<Nodes> 
    <telerik:RadTreeNode runat="server" Text="Products" ExpandMode="ClientSide"
       <Nodes> 
           <telerik:RadTreeNode runat="server" Text="Books" ExpandMode="ClientSide"
           <Nodes> 
               <telerik:RadTreeNode runat="server" Text="Fiction"></telerik:RadTreeNode> 
               <telerik:RadTreeNode runat="server" Text="Non-Fiction"></telerik:RadTreeNode> 
               <telerik:RadTreeNode runat="server" Text="Biography"></telerik:RadTreeNode> 
               <telerik:RadTreeNode runat="server" Text="Humor"></telerik:RadTreeNode> 
           </Nodes> 
           </telerik:RadTreeNode> 
       </Nodes> 
   </telerik:RadTreeNode> 
   </Nodes> 
</telerik:RadTreeView> 
<input id="Button1" type="button" value="Get the tree" onclick="gettreeview();"/> 

Thanks,
Shinu.
Tags
TreeView
Asked by
Ken
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or