Radtree inside RadPanelBar/RadPanelItem

4 posts, 0 answers
  1. Joshua Arend
    Joshua Arend avatar
    8 posts
    Member since:
    Apr 2010

    Posted 08 Apr 2010 Link to this post

    I had a Ajax Q1 2010 Tree working perfectly then decided to wrap it up in a RadPanelBar.  I'm loading it server side and used " Dim treeview As RadTreeView = DirectCast(RadPanelBar1.FindItemByValue("templateHolder").FindControl("RadTreeView1"), RadTreeView)" to gain access to the control.

    But...Node Click and Expand events are not firing.

    Thanks,
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 09 Apr 2010 Link to this post

    Hello Joshua Arend,

    I've tested the scenario but wasn't able to reproduce this issue. Could you please send us some sample code which will help us? Thanks

    Kind regards,
    Yana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Joshua Arend
    Joshua Arend avatar
    8 posts
    Member since:
    Apr 2010

    Posted 09 Apr 2010 Link to this post


    Here's an excerpt of the code that I put into a test page. 

    .aspx

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="OLD.aspx.vb" Inherits="OnlineAssessing.OLD" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head runat="server"
        <title>Untitled Page</title> 
    </head> 
    <body> 
        <form id="form1" runat="server"
         
        <telerik:RadScriptManager ID="ScriptManager1" runat="server" ></telerik:RadScriptManager> 
        <div> 
        <telerik:RadPanelBar runat="server" ID="RadPanelBar1" Height="450px" ExpandMode="FullExpandedItem"
                <Items> 
                    <telerik:RadPanelItem  Text="ParcelID" ImageUrl="Img/mail.gif" Expanded="True" runat="server"
                        <Items> 
                        <telerik:RadPanelItem Value="templateHolder" runat="server"
                                <ItemTemplate> 
                                    <telerik:RadTreeView id="RadTreeView1" AutoPostBack="True"  runat="server" height="400" Width="210px" ></telerik:RadTreeView>  
                                </ItemTemplate> 
                        </telerik:RadPanelItem> 
                        </Items> 
                    </telerik:RadPanelItem>                         
                </Items> 
            </telerik:RadPanelBar> 
        </div> 
        </form> 
    </body> 
    </html> 
     
    .vb

     
    Imports Telerik.Web.UI 
     
    Imports System.Web.UI.WebControls 
     
    Partial Public Class OLD 
        Inherits System.Web.UI.Page 
     
        Protected WithEvents RadTreeView1 As RadTreeView 
     
        Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load 
            LoadRootNodes() 
        End Sub 
     
     
        Private Sub LoadRootNodes() 
            Dim treeview As RadTreeView = DirectCast(RadPanelBar1.FindItemByValue("templateHolder").FindControl("RadTreeView1"), RadTreeView) 
     
     
            Dim node As New RadTreeNode() 
            node.Text = "Fruit" 
            node.ExpandMode = TreeNodeExpandMode.ServerSide 
            treeview.Nodes.Add(node) 
     
            Dim node1 As New RadTreeNode() 
            node1.Text = "Vegetables" 
            node1.ExpandMode = TreeNodeExpandMode.ServerSide 
            treeview.Nodes.Add(node1) 
     
            Dim node2 As New RadTreeNode() 
            node2.Text = "Grains" 
            node2.ExpandMode = TreeNodeExpandMode.ServerSide 
            treeview.Nodes.Add(node2) 
     
     
        End Sub 
     
        Private Sub RadTreeView1_NodeClick(ByVal sender As ObjectByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles RadTreeView1.NodeClick 
     
            Dim x As String = e.Node.Value.ToString 
            System.Diagnostics.Debug.Print(x) 
     
     
        End Sub 
     
        Private Sub RadTreeView1_NodeExpand(ByVal sender As ObjectByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles RadTreeView1.NodeExpand 
     
            Dim sql As String = "" 
     
            Select Case e.Node.LongDesc.ToUpper 
                Case "FRUIT" 
     
                    Dim node As New RadTreeNode() 
                    node.Text = "Apple" 
                    node.ExpandMode = TreeNodeExpandMode.ServerSide 
                    e.Node.Nodes.Add(node) 
     
                    Dim node1 As New RadTreeNode() 
                    node1.Text = "Orange" 
                    node1.ExpandMode = TreeNodeExpandMode.ServerSide 
                    e.Node.Nodes.Add(node1) 
     
                    Dim node2 As New RadTreeNode() 
                    node2.Text = "Pear" 
                    node2.ExpandMode = TreeNodeExpandMode.ServerSide 
                    e.Node.Nodes.Add(node2) 
     
                Case "VEGETABLES" 
     
     
                    Dim node As New RadTreeNode() 
                    node.Text = "Carrot" 
                    node.ExpandMode = TreeNodeExpandMode.ServerSide 
                    e.Node.Nodes.Add(node) 
     
                    Dim node1 As New RadTreeNode() 
                    node1.Text = "Corn" 
                    node1.ExpandMode = TreeNodeExpandMode.ServerSide 
                    e.Node.Nodes.Add(node1) 
     
                    Dim node2 As New RadTreeNode() 
                    node2.Text = "Peas" 
                    node2.ExpandMode = TreeNodeExpandMode.ServerSide 
                    e.Node.Nodes.Add(node2) 
                Case "GRAINS" 
     
     
                    Dim node As New RadTreeNode() 
                    node.Text = "Rice" 
                    node.ExpandMode = TreeNodeExpandMode.ServerSide 
                    e.Node.Nodes.Add(node) 
     
                    Dim node1 As New RadTreeNode() 
                    node1.Text = "Oats" 
                    node1.ExpandMode = TreeNodeExpandMode.ServerSide 
                    e.Node.Nodes.Add(node1) 
     
                    Dim node2 As New RadTreeNode() 
                    node2.Text = "Barley" 
                    node2.ExpandMode = TreeNodeExpandMode.ServerSide 
                    e.Node.Nodes.Add(node2) 
     
            End Select 
     
            e.Node.Expanded = True 
            e.Node.ExpandMode = TreeNodeExpandMode.ClientSide 
     
        End Sub 
    End Class 
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 12 Apr 2010 Link to this post

    Hi Joshua,

    Thank you for providing the code.

    You should subscribe to the events in the definition of the treeview, because it's not accessible directly in the code-behind (it's inside a template):

    <telerik:RadTreeView ID="RadTreeView1" AutoPostBack="True" runat="server" Height="400"
        Width="210px" OnNodeExpand=" RadTreeView1_NodeExpand"
        OnNodeClick="RadTreeView1_NodeClick">
    </telerik:RadTreeView>

    and the event handlers:

    Public Sub RadTreeView1_NodeClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs)
     
    End Sub
     
    Public Sub RadTreeView1_NodeExpand(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs)
     
    End Sub

    also the nodes should be added only this first time the page loads:

    If Not Page.IsPostBack Then
      LoadRootNodes()
    End If


    I've attached the modified page for a reference.

    Greetings,
    Yana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top