Hi Team,
How can we get the list of parent node value at a perticular level .?
My requirment is I have to pass the list of parent node value as a string ( each node will separated with a comma ) at a perticular level . If I am expanding the level 4 then , I need parentnodevalue(0),parentnodevalue(1),parentnodevalue(2),parentnodevalue(3),currentnodevalue(4) . can you suggest me
Regards
Manoj
How can we get the list of parent node value at a perticular level .?
My requirment is I have to pass the list of parent node value as a string ( each node will separated with a comma ) at a perticular level . If I am expanding the level 4 then , I need parentnodevalue(0),parentnodevalue(1),parentnodevalue(2),parentnodevalue(3),currentnodevalue(4) . can you suggest me
Regards
Manoj
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 06 Feb 2009, 10:54 AM
Hi Manoj,
I have used the following code to get the parent of a selected node.
You can loop through the node collection and get the parent nodes
foreach (RadTreeNode node in nodeCollection)
{
//Write the logic to find the parent up to the selected node.
}
-Shinu.
I have used the following code to get the parent of a selected node.
<radT:RadTreeView ID="RadTreeView1" runat="server" OnNodeClick="RadTreeView1_NodeClick" AutoPostBack=true> |
</radT:RadTreeView> |
protected void RadTreeView1_NodeClick(object o, RadTreeNodeEventArgs e) |
{ |
SelectParents(e.NodeClicked); |
} |
protected void SelectParents( RadTreeNode node) |
{ |
if (node.Parent != null) |
{ |
node.Parent.Selected = true; |
} |
} |
You can loop through the node collection and get the parent nodes
foreach (RadTreeNode node in nodeCollection)
{
//Write the logic to find the parent up to the selected node.
}
-Shinu.
0
Manoj
Top achievements
Rank 1
answered on 09 Feb 2009, 01:05 PM
Hi Shinu,
Thanks for your reply . But I getting compile time error when trying to check your suggested code . Can you look into it .
When I am expanding any perticular node , I need all the parent node values .
Regards
Manoj
Thanks for your reply . But I getting compile time error when trying to check your suggested code . Can you look into it .
When I am expanding any perticular node , I need all the parent node values .
Regards
Manoj
0
Shinu
Top achievements
Rank 2
answered on 11 Feb 2009, 09:13 AM
Hi Manoj,
Give a try with the following client side code and see whether it helps.
ASPX:
JS:
Thanks
Shinu
Give a try with the following client side code and see whether it helps.
ASPX:
<telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientNodeExpanding="ClientNodeExpanding" > |
<Nodes> |
...... |
JS:
<script type="text/javascript" > |
function ClientNodeExpanding(sender, eventArgs) |
{ |
var Tree=sender; |
var nodes=Tree.get_nodes(); |
var currentNode = eventArgs.get_node(); |
if(currentNode!=null) |
{ |
for(i=0;i<=nodes.get_count();i++) |
{ |
var nodeText=nodes.getNode(i).get_text(); |
alert(nodeText) |
if(nodeText==currentNode.get_text()) |
{ |
break; |
} |
} |
} |
} |
</script> |
Thanks
Shinu
0
Manoj
Top achievements
Rank 1
answered on 13 Feb 2009, 07:36 AM
Hi Shinu,
Thanks for you reply . I tried in a different manner . Here I have attached the code .
RadTreeNode
curNode;
String strNodeCollection = "";
String strNodeColl = "";
curNode = e.Node;
Int32 intSelectedNodeLevel;
intSelectedNodeLevel = e.Node.Level;
if (intSelectedNodeLevel >= 0)
{
for (int i = intSelectedNodeLevel; i >= 0; i--)
{
if (strNodeCollection == "")
{
strNodeColl = curNode.Value;
strNodeCollection = strNodeColl;
}
else
{
RadTreeNode tnode = curNode.ParentNode;
strNodeCollection = tnode.Value +
"," + strNodeCollection ;
curNode = tnode;
}
}
}
With Regards
Manoj
0
Richard
Top achievements
Rank 2
answered on 18 Jun 2009, 02:13 PM
Manoj,
Thanks, that method was EXACTLY what I was looking for!!!
Thanks, that method was EXACTLY what I was looking for!!!