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

RadPanel ItemTemplate won't collapse

1 Answer 77 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 03 Aug 2009, 04:20 PM
I have a rad panel that I have put a rad tree view in. However, now that the rad tree is within the panel, I cannot get it to collapse. It is always expanded and won't collapse even if you click the button. The two other panels have static data in them and they collapse fine. Can anyone help me with this issue? Here is my code

<%@ Master Language="VB" AutoEventWireup="false" Debug="True" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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">
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Data.Sql" %>
<%@ import namespace="System.Data.SqlClient" %>
<%@ import namespace="Telerik.Web.UI" %>

<script runat="server">
    
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        
        If Not Page.IsPostBack Then
            
            Dim tree As RadTreeView = DirectCast(RadPanelBar1.Items(0).FindControl("RadTreeView1"), RadTreeView)
            'here is where the error is. it is saying that
            'createtable is null
            tree.DataSource = CreateTable()
            tree.DataFieldID = "ID"
            tree.DataFieldParentID = "ParentID"
            tree.DataTextField = "Text"
            tree.DataBind()
                        
        End If
    End Sub 'page_load
    
    'this function creates a datatable for the rad
    'tree that is in the events panel
    Private Function CreateTable() As DataTable
        'set up my connection to the database
        Dim conn As New SqlConnection
        conn.ConnectionString = ConfigurationManager.ConnectionStrings("connectionString").ConnectionString

        Dim table As DataTable = New DataTable()
        table.Columns.Add("ID")
        table.Columns.Add("ParentID")
        table.Columns.Add("Text")

        'this is a counter for the id fields
        'of the data table
        Dim count As Integer = 1
        
        'this adds the parent categories to the
        'datatable
        Dim categoryQuery As New SqlCommand
        conn.Open()
        categoryQuery.Connection = conn
        categoryQuery.CommandText = "select CategoryId, Name from categories"
        Dim cdr As SqlDataReader = categoryQuery.ExecuteReader()
        While cdr.Read()
            
            If (cdr.Item(0).ToString <> "") Then
                
                table.Rows.Add(New String() {count.ToString, Nothing, cdr.Item(1).ToString})
                'we have to increment count to keep an id for the data table
                count = count + 1
                
            End If
            
        End While 'while cdr.Read()
        conn.Close()
        conn.Open()
        'this adds the events with their parent category
        'id to the datatable
        Dim eventQuery As New SqlCommand
        eventQuery.Connection = conn
        eventQuery.CommandText = "SELECT eventid, FK_CategoryID, name from events"
        Dim edr As SqlDataReader = eventQuery.ExecuteReader()
        While edr.Read()
            
            If (edr.Item(0).ToString <> "") Then
                
                table.Rows.Add(New String() {count.ToString(), edr.Item(1).ToString, edr.Item(2).ToString})
                'we have to increment count to keep an id for the data table
                count = count + 1
                
            End If
            
        End While 'while edr.Read()
               
        Return table

    End Function 'CreateGenreTable

</script>

<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadPanelBar ID="RadPanelBar1" runat="server" Skin="Web20" ExpandMode="SingleExpandedItem">
        <CollapseAnimation Type="None" Duration="100"></CollapseAnimation>
        <Items>
            <telerik:RadPanelItem runat="server" Text="Events">
                <ItemTemplate>
                    <telerik:RadTreeView ID="RadTreeView1" runat="server" Skin="Web20">
                        <CollapseAnimation Type="OutQuint" Duration="100"></CollapseAnimation>
                        <ExpandAnimation Duration="100"></ExpandAnimation>
                    </telerik:RadTreeView>
                </ItemTemplate>
            </telerik:RadPanelItem>
            <telerik:RadPanelItem runat="server" Text="Calendar">
                <Items>
                    <telerik:RadPanelItem runat="server" Text="Child RadPanelItem 1">
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem runat="server" Text="Child RadPanelItem 2">
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelItem>
            <telerik:RadPanelItem runat="server" Text="Root RadPanelItem3">
                <Items>
                    <telerik:RadPanelItem runat="server" Text="Child RadPanelItem 1">
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem runat="server" Text="Child RadPanelItem 2">
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelItem>
        </Items>
        <ExpandAnimation Type="None" Duration="100"></ExpandAnimation>
    </telerik:RadPanelBar>
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

In case you want to see what I'm trying to do. You can go here
http://alpha.clickablecommunity.com/

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 05 Aug 2009, 02:53 PM
Hello,

Please check this forum post - I believe it will answer your question.

Regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
PanelBar
Asked by
Web Services
Top achievements
Rank 2
Answers by
Veselin Vasilev
Telerik team
Share this question
or