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

Perform two actions on node text click?

1 Answer 37 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 29 Jun 2012, 04:53 AM
I have a treeview that is set to load on demand. When the node text is clicked I want to both expand the node if it is expandable and trigger the Node Click event in code behind. below is what I have so far. Is this even possible?

    Protected Sub radprojecttree_NodeExpand(sender As Object, e As Telerik.Web.UI.RadTreeNodeEventArgsHandles radprojecttree.NodeExpand         
        If (Not SiteUser Is NothingThen             
            BSRMaster.navtree.NavTree_InitNodes(Nothing, e.Node)         
        End If     
    End Sub     
    Protected
 Sub radprojecttree_NodeClick(sender As Object, e As Telerik.Web.UI.RadTreeNodeEventArgsHandles radprojecttree.NodeClick         
        Dim ts As String = e.Node.Attributes("contentpage")         
        radpancontentholder.ContentUrl = ts             
        Me.radprojecttree_NodeExpand(sender, e)           
    End Sub

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Jun 2012, 06:57 AM
Hi Mathew,

Try the following code snippet to achieve your scenario.

VB:
Private 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("name").ToString()
        node.Value = row("id").ToString()
        If Convert.ToInt32(row("ChildrenCount")) > 0 Then
            node.ExpandMode = expandMode
        End If
        e.Node.Nodes.Add(node)
    Next
 
    e.Node.Expanded = True
End Sub
Protected Sub radprojecttree_NodeClick(sender As Object, e As RadTreeNodeEventArgs)
    If e.Node.Nodes.Count = 0 Then
        PopulateNodeOnDemand(e, TreeNodeExpandMode.ServerSide)
    End If
End Sub

Hope this helps.

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