Radtreeview selected node text and value displaying null?

4 posts, 1 answers
  1. Bhuvan
    Bhuvan avatar
    50 posts
    Member since:
    Dec 2010

    Posted 24 Mar 2011 Link to this post

    Hi,

    I ha a RadTreeview like this
    <telerik:RadTreeView ID="RadTreeView_CommonControls" runat="server" 
        Skin="Windows7" OnClientDoubleClick="SetPlaceHolders">
          <Nodes>
     <telerik:RadTreeNode Text="Text Controls">
      <Nodes>
    <telerik:RadTreeNode Text="Text Area" Value="<Text Area></Text Area>"></telerik:RadTreeNode>
    <telerik:RadTreeNode Text="Regards Template" Value="<Regards></Regards>"></telerik:RadTreeNode>
    <telerik:RadTreeNode Text="Intro Template" Value="<Intro></Intro>"></telerik:RadTreeNode>
     <telerik:RadTreeNode Text="Sat Intro Template"  Value="<About Sat></About Sat>"></telerik:RadTreeNode>
    </Nodes>
    </telerik:RadTreeNode>
    <telerik:RadTreeNode Text="Audio Controls">
     <Nodes>
    <telerik:RadTreeNode Text="Embed Audio" Value="<Embed Audio></Embed Audio>"></telerik:RadTreeNode>
    <telerik:RadTreeNode Text="Upload Audio" Value="<Upload Audio></Upload Audio>"></telerik:RadTreeNode>
    <telerik:RadTreeNode Text="Upload BGM" Value="<Upload BGM></Upload BGM>"></telerik:RadTreeNode>                                                        
     </Nodes>
    </telerik:RadTreeNode>
    <telerik:RadTreeNode Text="Video Controls">
     <Nodes>
      <telerik:RadTreeNode Text="Embed Video"  Value="<Embed Video></Embed Video>"></telerik:RadTreeNode>
    <telerik:RadTreeNode Text="Upload Video"  Value="<Embed Video></Embed Video>"></telerik:RadTreeNode>
    <telerik:RadTreeNode Text="Upload Video and Audio"  Value="<Embed Video></Embed Video>"></telerik:RadTreeNode>                                                        
    </Nodes>
    </telerik:RadTreeNode>                                                    
        </Nodes>
    </telerik:RadTreeView>

    I am trying to access the selected node value and text when i double click on node

    Javascript function
    function SetPlaceHolders(sender, args) {
            var TreeView = $find("<%=RadTreeView_CommonControls.ClientID%>");
            var SelectedNode_Tree = TreeView.get_selectedNode();
            SelectedNode_Tree = TreeView.SelectedNode;
            debugger;
              
        }

    var SelectedNode_Tree = TreeView.get_selectedNode(); //This is displaying Null
            SelectedNode_Tree = TreeView.SelectedNode; // This raising as Undefined


    Will u please help me to fnd out this?
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Mar 2011 Link to this post

    Hello Bhuvan,

    Try the following code snippet to get the selected node.

    Java Script:
    <script type="text/javascript">
        function SetPlaceHolders(sender, args) {
            debugger;
            var TreeView = $find("<%=RadTreeView_CommonControls.ClientID%>");
            var SelectedNode_Tree= TreeView.get_selectedNodes()[0].get_text();
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. rajaganapathi
    rajaganapathi avatar
    3 posts
    Member since:
    Jun 2011

    Posted 23 Jun 2011 Link to this post

    Hi Princy,
                 Even the below code returns only null ... Could you please help me.... I need to upadte the breadcrumb on click of every node in radtreeview.

    <script type="text/javascript">

        function SetPlaceHolders(sender, args) {
            debugger;
            var TreeView = $find("<%=RadTreeView_CommonControls.ClientID%>");
            var SelectedNode_Tree= TreeView.get_selectedNodes()[0].get_text();
        }
    </script>

     

  5. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 24 Jun 2011 Link to this post

    Hello rajaganapathi,

    Here is another way to access the text or value of a node:

    function SetPlaceHolders(sender, args) {
              var SelectedNode_Tree = args._node.get_text();
              alert(SelectedNode_Tree);
          }

    As a matter of fact the option that was offered by Mr. Princy Philip worked fine as well in my simple project.

    Hope this works for you.

    Greetings,
    Plamen Zdravkov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top