Hello
not sure if this has been already solved
I am using Radtree and all the nodes are created dynamically from the DB
Some of the nodes have Child nodes some don't
how is that i can find out whether it is a child node or not
How can i say that's the child node was clicked
So please suggest
Thanks
Kavya
not sure if this has been already solved
I am using Radtree and all the nodes are created dynamically from the DB
Some of the nodes have Child nodes some don't
how is that i can find out whether it is a child node or not
How can i say that's the child node was clicked
So please suggest
Thanks
Kavya
11 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 09 Dec 2008, 08:23 AM
Hi Kaya,
Try the following code snippet to check whether a clicked node is child node or not.
CS:
Regards
Shinu.
Try the following code snippet to check whether a clicked node is child node or not.
CS:
protected void RadTreeView1_NodeClick(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e) |
{ |
if (e.Node.Nodes.Count == 0) |
{ |
Response.Write("CHILD NODE"); |
} |
else |
{ |
Response.Write("PARENT NODE"); |
} |
} |
Regards
Shinu.
0

Kavya
Top achievements
Rank 2
answered on 10 Dec 2008, 10:37 PM
Hi Shinu
When i type in this e.Node.Nodes.Count
It says nodes is not a member of TreeNodeeventArgs
Do let me know what i can do
Thanks
Kavya
When i type in this e.Node.Nodes.Count
It says nodes is not a member of TreeNodeeventArgs
Do let me know what i can do
Thanks
Kavya
0

Shinu
Top achievements
Rank 2
answered on 11 Dec 2008, 05:19 AM
Hi Kavya,
Can you try with the following client side code and see if is working?
ASPX:
JS:
Regards
Shinu
Can you try with the following client side code and see if is working?
ASPX:
<telerik:RadTreeView ID="RadTreeView1" OnClientNodeClicking="OnClientNodeClicking" runat="server" > |
</telerik:RadTreeView> |
JS:
<script type="text/javascript"> |
function OnClientNodeClicking(sender, eventArgs) |
{ |
var node = eventArgs.get_node(); |
if(node.get_nodes().get_count()>0) |
{ |
alert('Has Child Nodes') |
} |
else |
alert('No Child Nodes') |
} |
</script> |
Regards
Shinu
0

Kavya
Top achievements
Rank 2
answered on 11 Dec 2008, 03:49 PM
Hello Shinu
I am using 6.1.1 version
is there an upgrade i need to do as i don't see OnClientNodeClicking on my TreeView Tab
Thanks
Kavya
I am using 6.1.1 version
is there an upgrade i need to do as i don't see OnClientNodeClicking on my TreeView Tab
Thanks
Kavya
0

Shinu
Top achievements
Rank 2
answered on 12 Dec 2008, 10:25 AM
Hi Kavya,
I hope you are using RadTreeView for asp.net. In that case you need to use BeforeClientClick event instead of OnClientNodeClicking event. Try the following code snippet instead.
ASPX:
JS:
Thanks
Shinu
I hope you are using RadTreeView for asp.net. In that case you need to use BeforeClientClick event instead of OnClientNodeClicking event. Try the following code snippet instead.
ASPX:
<rad:RadTreeView ID="RadTreeView2" BeforeClientClick="BeforeClientClick" runat="server"> |
JS:
<script type="text/javascript"> |
function BeforeClientClick(node, eventArgs) |
{ |
var treenode=node; |
var childNodeCount=treenode.Nodes.length; |
if(childNodeCount>0) |
{ |
alert('Has Child Nodes') |
} |
else |
alert('No Child Nodes') |
} |
</script > |
Thanks
Shinu
0

Kavya
Top achievements
Rank 2
answered on 17 Dec 2008, 09:13 PM
Hi Srinu
Is there a way i can use this method on Radtree click(code behind)
That is where i need the count .
When i click Child Node how will i know thatis the child node
Kavya
Is there a way i can use this method on Radtree click(code behind)
That is where i need the count .
When i click Child Node how will i know thatis the child node
Kavya
0

Shinu
Top achievements
Rank 2
answered on 18 Dec 2008, 05:08 AM
Hi Kavya,
Give a try with the following code snippet.
CS:
Regards
Shinu
Give a try with the following code snippet.
CS:
protected void RadTreeView1_NodeClick(object o, Telerik.WebControls.RadTreeNodeEventArgs e) |
{ |
if (e.NodeClicked.Nodes.Count>0) |
{ |
Response.Write(" HAS CHILD NODE"); |
} |
else |
{ |
Response.Write("NO CHILD NODE"); |
} |
} |
Regards
Shinu
0

Kavya
Top achievements
Rank 2
answered on 18 Dec 2008, 03:38 PM
shinu
the above code tells me whether it has child or not
How would i know whether child node was clicked not all nodes will be having Child nodes.
i changed my code a way around for now so that my code works is
Added "-" in front of each child node when i am dynamically adding nodes to the tree
so when RadTree node is clicked if selected text contains "-" then its child node
Kavya
the above code tells me whether it has child or not
How would i know whether child node was clicked not all nodes will be having Child nodes.
i changed my code a way around for now so that my code works is
Added "-" in front of each child node when i am dynamically adding nodes to the tree
so when RadTree node is clicked if selected text contains "-" then its child node
Kavya
0

Shinu
Top achievements
Rank 2
answered on 22 Dec 2008, 10:55 AM
Hello,
You just need to check whether e.NodeClicked.Nodes.Count is equal to zero to check whether the clicked node is a child node.
CS:
Shinu
You just need to check whether e.NodeClicked.Nodes.Count is equal to zero to check whether the clicked node is a child node.
CS:
protected void RadTreeView2_NodeClick(object o, Telerik.WebControls.RadTreeNodeEventArgs e) |
{ |
if (e.NodeClicked.Nodes.Count== 0) |
{ |
Response.Write(" You have clicked child node"); |
} |
} |
Shinu
0

Kavya
Top achievements
Rank 2
answered on 22 Dec 2008, 09:25 PM
Hello Shinu
the code which you sent me will work good for the all nodes having child nodes.
But in my code some of them have Child nodes some of them don't
So the code which you gave me
the count is coming out to be zero even for thr nodes which deosn't have child nodes
Thanks
Kavya
the code which you sent me will work good for the all nodes having child nodes.
But in my code some of them have Child nodes some of them don't
So the code which you gave me
the count is coming out to be zero even for thr nodes which deosn't have child nodes
Thanks
Kavya
0

Shinu
Top achievements
Rank 2
answered on 23 Dec 2008, 05:45 AM
Hi,
Try with the following code snippet and see if it helps.
CS:
Shinu.
Try with the following code snippet and see if it helps.
CS:
protected void RadTreeView2_NodeClick(object o, Telerik.WebControls.RadTreeNodeEventArgs e) |
{ |
if ((e.NodeClicked.Nodes.Count== 0)&&(e.NodeClicked.Parent!=null)) |
{ |
Response.Write(" You have clicked child node"); |
} |
} |
Shinu.