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

Selecting a parent node in client side which is also a root node

3 Answers 129 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Preetam Ray
Top achievements
Rank 1
Preetam Ray asked on 02 Sep 2008, 03:27 PM
Hi,
The treeview sctructure I am using in my project is like given below

Node1
    childnode11
    childnode12
Node2
    childnode21
     childnode22

all the nodes have check boxes. My requirement is when ever the child node is checked I have to check (select) the parent node also in client side.but when i check the "childnode11" the function node.get_parent()  returns me an instance of  the treeview as "Node1" is the root node. so when i try to set something like node.get_parent().check() it gives me a java script error saying "check is not a function"
Can you please let me know how to find an instance of parent node which is also a root node and select/unslect it using the client side functions.

Thanks!

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Sep 2008, 09:39 AM
Hi Preetam,

Try the following code snippet to achieve the desired scenario.

ASPX:
<telerik:RadTreeView ID="RadTreeView1"   OnClientNodeChecking="OnClientNodeChecking"      runat="server" CheckBoxes="True" > 
                 

JS:
 <script type="text/javascript" language="javascript" > 
     
    function OnClientNodeChecking(sender, eventArgs) 
    { 
     var node = eventArgs.get_node(); 
      node.get_parent().set_checked(true); 
    
    } 
 </script> 


Thanks
Shinu.
0
Preetam Ray
Top achievements
Rank 1
answered on 03 Sep 2008, 02:45 PM
Thanks! Shinu

But this does not solve my problem completely.  node.get_parent() returns the instance of treeview if the parent node is also a root node .
How do I determine whether the instance returned is treeview or just a node. 
Depending on whether its a root node or intermediate node I have to implement different logic.


0
Shinu
Top achievements
Rank 2
answered on 04 Sep 2008, 07:16 AM
Hi Preetam,

You can try the following JS code to determine whether the clicked node is is a root node or not.

JS:
 function OnClientNodeChecking(sender, eventArgs) 
    { 
     var node = eventArgs.get_node(); 
       if(node.get_parent() != node.get_treeView()) 
         { 
           node.get_parent().set_checked(true);  
         }  
    
    } 


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