Accord Dev Team
Top achievements
Rank 1
Accord Dev Team
asked on 16 Apr 2014, 01:35 PM
Hi,
I need to emulate the expand node by lod on demand through js or vb.net code.
Could you help me?
Thanks,
Marcos
I need to emulate the expand node by lod on demand through js or vb.net code.
Could you help me?
Thanks,
Marcos
3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 17 Apr 2014, 05:35 AM
Hi Horacio Judeikin,
I guess that you want to expand a RadTreeNode which loaded by LoadOnDeamd. You can try the following VB.net Code snippet to expand the RadTreeNode on the Button onClick event.
VB:
Please elaborate your requirement if it doesn't help.
Thanks,
Shinu.
I guess that you want to expand a RadTreeNode which loaded by LoadOnDeamd. You can try the following VB.net Code snippet to expand the RadTreeNode on the Button onClick event.
VB:
Protected Sub RadButton1_Click(sender As Object, e As EventArgs) Dim node As RadTreeNode = TryCast(RadTreeView1.Nodes.FindNodeByText("Politics"), RadTreeNode) node.Expanded = TrueEnd SubPlease elaborate your requirement if it doesn't help.
Thanks,
Shinu.
0
Accord Dev Team
Top achievements
Rank 1
answered on 17 Apr 2014, 05:30 PM
Hi Shinu,
I tried it and it does not work. Only works when the node is clientside.
Any idea?
Thanks,
Marcos
I tried it and it does not work. Only works when the node is clientside.
Any idea?
Thanks,
Marcos
0
Shinu
Top achievements
Rank 2
answered on 19 Apr 2014, 05:38 AM
Hi Horacio Judeikin,
Please have a look into the sample code snippet which works fine at my end. Please try to replicate the problem in this code for further help.
ASPX:
VB:
Thanks,
Shinu.
Please have a look into the sample code snippet which works fine at my end. Please try to replicate the problem in this code for further help.
ASPX:
<telerik:RadTreeView ID="RadTreeView1" runat="server" Height="300px" Width="100%" OnNodeExpand="RadTreeView1_NodeExpand"></telerik:RadTreeView><telerik:RadButton ID="RadButton1" runat="server" Text="Expand" OnClick="RadButton1_Click"></telerik:RadButton>VB:
Protected Sub Page_Load(sender As Object, e As EventArgs) If Not Page.IsPostBack Then LoadRootNodes(RadTreeView1, TreeNodeExpandMode.ServerSideCallBack) End IfEnd SubProtected Sub RadTreeView1_NodeExpand(sender As Object, e As RadTreeNodeEventArgs) PopulateNodeOnDemand(e, TreeNodeExpandMode.ServerSideCallBack)End SubPrivate Shared Sub PopulateNodeOnDemand(e As RadTreeNodeEventArgs, expandMode As TreeNodeExpandMode) Dim data As DataTable = GetChildNodes(e.Node.Value) For Each row As DataRow In data.Rows Dim node As New RadTreeNode() node.Text = row("text").ToString() node.Value = row("id").ToString() e.Node.Nodes.Add(node) Next e.Node.Expanded = TrueEnd SubPrivate Shared Function GetChildNodes(parentId As String) As DataTable Dim selectCommand As New SqlCommand((Convert.ToString("select id,text from Details where parentid='") & parentId) + "'") Return GetData(selectCommand)End FunctionPrivate Shared Function GetData(selectCommand As SqlCommand) As DataTable selectCommand.Connection = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString) Dim adapter As New SqlDataAdapter(selectCommand) Dim data As New DataTable() adapter.Fill(data) Return dataEnd FunctionPrivate Shared Sub LoadRootNodes(treeView As RadTreeView, expandMode As TreeNodeExpandMode) Dim data As DataTable = GetData(New SqlCommand("SELECT * FROM Details WHERE parentid IS NULL")) For Each row As DataRow In data.Rows Dim node As New RadTreeNode() node.Text = row("text").ToString() node.Value = row("id").ToString() node.ExpandMode = expandMode treeView.Nodes.Add(node) NextEnd SubProtected Sub RadButton1_Click(sender As Object, e As EventArgs) Dim node As RadTreeNode = TryCast(RadTreeView1.Nodes.FindNodeByText("Politics"), RadTreeNode) node.Expanded = TrueEnd SubThanks,
Shinu.