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

How to get checked nodes of RadTreeViewControl from RadWindow?

1 Answer 351 Views
Window
This is a migrated thread and some comments may be shown as answers.
jasear
Top achievements
Rank 1
jasear asked on 23 Jun 2009, 11:31 AM
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.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Jun 2009, 07:23 AM
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



Tags
Window
Asked by
jasear
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or