6 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 04 Jul 2014, 09:56 AM
Hi Andy,
Try to use the client side expand method to expand a particular node. Please have a look into the sample code snippet which expands a node from JavaScript.
ASPX:
JavaScript:
Thanks,
Shinu.
Try to use the client side expand method to expand a particular node. Please have a look into the sample code snippet which expands a node from JavaScript.
ASPX:
<telerik:RadTreeView ID="rtreeviewTestDemo" runat="server"> <Nodes> <telerik:RadTreeNode Text="Node1"> <Nodes> <telerik:RadTreeNode Text="Node1.1"> </telerik:RadTreeNode> <telerik:RadTreeNode Text="Node1.2"> </telerik:RadTreeNode> </Nodes> </telerik:RadTreeNode> </Nodes></telerik:RadTreeView>JavaScript:
function pageLoad() { var node = $find("<%=rtreeviewTestDemo.ClientID%>"); node.findNodeByText("Node1").expand();}Thanks,
Shinu.
0
Andy
Top achievements
Rank 1
answered on 04 Jul 2014, 10:12 AM
Thanks for the suggestions. Unfortunately I need to be able to do this server side, do
you have a C# example please?
you have a C# example please?
0
Shinu
Top achievements
Rank 2
answered on 04 Jul 2014, 10:33 AM
Hi Andy,
Please try the below C# code snippet.
C#:
Thanks,
Shinu.
Please try the below C# code snippet.
C#:
RadTreeNode node = rtreeviewTestDemo.Nodes.FindNodeByText("Node1") as RadTreeNode;node.Expanded = true;Thanks,
Shinu.
0
Andy
Top achievements
Rank 1
answered on 04 Jul 2014, 02:27 PM
Hi,
Thanks for the suggestion, unfortunately it does not expand the treeview?
Thanks for the suggestion, unfortunately it does not expand the treeview?
0
Shinu
Top achievements
Rank 2
answered on 07 Jul 2014, 02:51 AM
Hi Andy,
Unfortunately I couldn't replicate the issue at my end. In order to expand a node try to set the Expanded property and ExpandChildNodes & ExpandParentNodes methods are there to expand the child node and parent node of a RadTreeNode. Please have a look into the sample code snippet which works fine at my end.
ASPX:
C#:
Please provide your code if it doesn't help.
Thanks,
Shinu.
Unfortunately I couldn't replicate the issue at my end. In order to expand a node try to set the Expanded property and ExpandChildNodes & ExpandParentNodes methods are there to expand the child node and parent node of a RadTreeNode. Please have a look into the sample code snippet which works fine at my end.
ASPX:
<telerik:RadTreeView ID="rtreeviewTestDemo" runat="server"> <Nodes> <telerik:RadTreeNode Text="Node1"> <Nodes> <telerik:RadTreeNode Text="Node1.1"> <Nodes> <telerik:RadTreeNode Text="Node1.11"> </telerik:RadTreeNode> <telerik:RadTreeNode Text="Node1.12"> </telerik:RadTreeNode> </Nodes> </telerik:RadTreeNode> <telerik:RadTreeNode Text="Node1.2"> </telerik:RadTreeNode> </Nodes> </telerik:RadTreeNode> </Nodes></telerik:RadTreeView>C#:
protected void Page_Load(object sender, EventArgs e){ RadTreeNode parentNode = rtreeviewTestDemo.Nodes.FindNodeByText("Node1") as RadTreeNode; RadTreeNode childNode = parentNode.Nodes.FindNodeByText("Node1.1") as RadTreeNode; parentNode.ExpandChildNodes(); childNode.ExpandParentNodes();}Please provide your code if it doesn't help.
Thanks,
Shinu.
0
Doug
Top achievements
Rank 1
answered on 01 Aug 2014, 09:15 PM
I expand each with a loop that travels up the tree
Dim node As RadTreeNode = RadTreeView1.FindNodeByAttribute("CategoryId", Request.QueryString("CategoryID"))
If Not IsNothing(node) Then
node.Selected = True
node.Expanded = True
...
End If
While (Not IsNothing(node))
node.ExpandParentNodes()
...
node.ExpandMode = TreeNodeExpandMode.ClientSide
node = node.ParentNode
End While
Dim node As RadTreeNode = RadTreeView1.FindNodeByAttribute("CategoryId", Request.QueryString("CategoryID"))
If Not IsNothing(node) Then
node.Selected = True
node.Expanded = True
...
End If
While (Not IsNothing(node))
node.ExpandParentNodes()
...
node.ExpandMode = TreeNodeExpandMode.ClientSide
node = node.ParentNode
End While