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

Cannot get the Selected Node from the ClientSide

1 Answer 246 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
MMagnumPI9
Top achievements
Rank 1
MMagnumPI9 asked on 25 Jul 2008, 08:20 PM

I am trying to find the selected node in a TreeView on the client side.

I have tried the code in this example which is linked to in a similar thread listed here.

I am not able to figure out what I am doing wrong.  When calling GetSelectedNodes() I contiune to get the error message "Object does not support this property or method".  I have tried setting MultiSelect = true and false with the same error.

Here is a sample of my code.

<body> 
    <script type="text/javascript">  
        function getSelectedNodes()  
        {  
            var tree = <%= RadTreeView1.ClientID %>;  
            var nodes = tree.GetSelectedNodes();  
            alert(nodes.length);  
        }  
    </script> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager> 
    <telerik:RadTreeView ID="RadTreeView1" runat="server">  
        <Nodes> 
            <telerik:RadTreeNode runat="server" Expanded="True" Text="1" Value="1" /> 
        </Nodes> 
    </telerik:RadTreeView> 
    <input id="Button1" type="button" value="Get Selected Node" onclick="getSelectedNodes();" /> 
    </form> 
</body> 


Justin

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 28 Jul 2008, 11:11 AM
Hi Justin,

Thank you for contacting Telerik Support.

The example you've tried is about "Classic" RadTreeView. For RadTreeView for ASP.NET AJAX you should use the following approach:

<script type="text/javascript">     
 function getSelectedNodes()     
 {     
    var tree= $find("<%= RadTreeView1.ClientID %>");  
    var nodes = tree.get_selectedNodes();  
    alert(nodes.length);    
 }    
</script> 

You can read more about RadTreeView object here. Please check out the attached sample project for a reference.

All the best,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
MMagnumPI9
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or