How to get checked nodes of RadTreeViewControl from RadWindow?

2 posts, 0 answers
  1. jasear
    jasear avatar
    29 posts
    Member since:
    Jan 2007

    Posted 23 Jun 2009 Link to this post

    Hi,

    I have a control on a normal aspx page. Next to it I have a button. I click on this button and it opens up a RadWindow. In the RadWindow I have a RadTreeViewControl in which I have checkboxes enabled. Once the user selects the appropriate checkboxes they click on the submit button which closes the rad window and should update the parent window.

    However I cannot get the values for the checkednodes in the parent window. When I try tree.get_checkedNodes().length I get the correct int number that represents how many nodes are checked. However I am not sure on how to get the text for the checked nodes.
    I want print out the text of the checked nodes in the parent window based on what was selected in the RadWindow.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Jun 2009 Link to this post

    Hi jasear,

    Try the following code snippet to get the checked node text of the RadTreeView (which is inside the child window) in the Parent page on closing the child window.



    //Page loading inside the Child window

    ASPX:



     
     <asp:Button ID="Button1" runat="server" OnClientClick=" GetRadWindow();" Text="Button" /><br /> 
        
          
             
            <telerik:RadTreeView ID="RadTreeView1" CheckBoxes="true"   EnableDragAndDrop="true" EnableDragAndDropBetweenNodes="true" runat="server"
             <Nodes> 
               <telerik:RadTreeNode Text="Node1"  > 
                <Nodes> 
                  <telerik:RadTreeNode Text="Child1" ></telerik:RadTreeNode> 
                   <telerik:RadTreeNode Text="Child2" ></telerik:RadTreeNode> 
                </Nodes> 
               </telerik:RadTreeNode> 
               <telerik:RadTreeNode Text="Node2" > 
               <Nodes> 
                  <telerik:RadTreeNode Text="Child1" ></telerik:RadTreeNode> 
                   <telerik:RadTreeNode Text="Child2" ></telerik:RadTreeNode> 
                </Nodes> 
               </telerik:RadTreeNode> 
               <telerik:RadTreeNode Text="Node3" > 
               <Nodes> 
                  <telerik:RadTreeNode Text="Child1" ></telerik:RadTreeNode> 
                   <telerik:RadTreeNode Text="Child2" ></telerik:RadTreeNode> 
                </Nodes> 
               </telerik:RadTreeNode> 
             </Nodes> 
            </telerik:RadTreeView> 

    JS:
     
    <script type="text/javascript" > 
     
    function GetRadWindow() 
      
      var oWindow = null
       
       if (window.frameElement) 
      { 
         oWindow = window.frameElement.radWindow; 
         oWindow.close(); 
          
      } 
     
    }   
     
    //function to get the checked node text of TreeView
    function GetCheckNodes() 
     var tree=$find("<%= RadTreeView1.ClientID %>");   
     var nodes=tree.get_nodes(); 
      for (i=0; i<nodes.get_count(); i++) 
       { 
        
           if (nodes.getNode(i).get_checked()) 
           { 
           alert(nodes.getNode(i).get_textElement().innerHTML
           } 
       } 
     
     
    </script> 


    //Parent page

    ASPX:
     
      <telerik:RadWindow ID="RadWindow1" runat="server" OnClientClose="Close" ></telerik:RadWindow> 
             
              <input id="Button2" type="button" value="ShowWindow" onclick="GetRadWindow();"  /> 

    JS:
     
    <script type="text/javascript" > 
    function GetRadWindow() 
        var oWnd = $find("<%=RadWindow1.ClientID%>"); 
        oWnd.setUrl('Test.aspx'); 
        oWnd.show(); 
     
     
    function Close() 
      var oWnd =  $find("<%=RadWindow1.ClientID%>");  
     
     //calling the client function from the page that is loaded inside the child window 
     oWnd.get_contentFrame().contentWindow.GetCheckNodes(); 
      
    </script> 


    Regards
    Shinu



Back to Top