5 Answers, 1 is accepted
I guess there's some misunderstanding here. Let me explain.
You cannot collapse a header panel item with a template. Here's a sample:
Item1
--template
Item2
--template
In this case, you cannot collapse Item1 and Item2.
Here's how the panelbar structure should look as to achieve your goal:
Item1
-- (RadpanelItem without text)
--template
Item2
-- (RadpanelItem without text)
--template
Regards,
Paul
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Paul, I'm trying to do something similar.
So, you are saying that instead of having:
<ItemTemplate> template here </ItemTemplate>
We should instead have:
<Items> <telerik:RadPanelItem> <ItemTemplate> </ItemTemplate> </telerik:RadPanelItem> </Items>
If I get you correctly, how exactly can I add say, a new datagrid into each of these item-templates programmatically?
I am databinding the panelbar.
I'm specifically looking for the code to create a new Item, radpanelitem and itemtemplate in the RadPanelBar1.ItemDataBound event
I will then take the key from the current row, and insert my datagrid into the template.
I do have a simple project with a bare bones setup if would like it, studio 2008 Pro targeting 3.5
I'm actually looking at using the panelbar as an accordion replacement, due to the many problems with using a radgrid inside an accordion.
Let me know if you have any other thoughts. I'm interested in alternate ways of doing this currently, as the accordion sucks so bad for databound uses.
( EDIT: Go look for the May patch at http://www.codeplex.com/AjaxControlToolkit/WorkItem/View.aspx?WorkItemId=11055
I haven't finished all my work with the gridviews inside the accordion yet, but this seems to have helped a few people with databinding accordions.
Be prepared to rebuild the entire toolkit on your local box using VS 2005 )

It appears that we are trying to accomplish basically the same thing. I am trying to replace an accordian with a panelbar where each pane contains a databound grid. One difference is that my panel bar is not databound, just the grids that are contained within. Here is my thread asking basically the same question you have (http://www.telerik.com/community/forums/thread/b311D-bgtmkb.aspx). What I have gotten so far is creating the Items and adding the controls according to what telerik says will work. You can follow that link above to get the code that I am using, but I am seeing basically the same problems as you. If you get any further on this, please post your resolution so that I can fix mine as well.
Thanks,
Lee

It displays correctly now, but I have no idea about functionality.
I actually need to put some commandbuttons in the grid, but now I need to look up how to create all the grid stuff programmatically...
Here is the aspx:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="AGridTest.aspx.vb" Inherits="POSWizard.AGridTest" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> |
<!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>a grid test</title> |
</head> |
<body> |
<form id="form1" runat="server"> |
<asp:ScriptManager ID="ScriptManager1" runat="server"> |
</asp:ScriptManager> |
<div> |
<telerik:RadPanelBar ID="RadPanelBar1" runat="server" Skin="WebBlue" ExpandAnimation-Type="Linear" ExpandMode="SingleExpandedItem" CollapseAnimation-Type="Linear"> |
<Items> |
<telerik:RadPanelItem> |
<ItemTemplate> |
</ItemTemplate> |
</telerik:RadPanelItem> |
</Items> |
<CollapseAnimation Type="Linear" Duration="100"></CollapseAnimation> |
<ExpandAnimation Type="Linear" Duration="100"></ExpandAnimation> |
</telerik:RadPanelBar> |
<br /> |
end of panelbar |
<br /> |
</div> |
</form> |
</body> |
</html> |
and the .vb:
Imports Telerik.Web.UI |
Partial Public Class AGridTest |
Inherits System.Web.UI.Page |
Dim ds As DataSet |
Private Sub AGridTest_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init |
End Sub |
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
If Not IsPostBack Then |
getdata() |
End If |
End Sub |
Sub getdata() |
Dim table As DataTable = New DataTable("table") |
Dim column As DataColumn |
Dim row As DataRow |
column = New DataColumn() |
column.DataType = System.Type.GetType("System.Int32") |
column.ColumnName = "id" |
column.ReadOnly = True |
column.Unique = True |
table.Columns.Add(column) |
column = New DataColumn() |
column.DataType = System.Type.GetType("System.String") |
column.ColumnName = "Item" |
column.AutoIncrement = False |
column.Caption = "Item" |
column.ReadOnly = False |
column.Unique = False |
table.Columns.Add(column) |
Dim PrimaryKeyColumns(0) As DataColumn |
PrimaryKeyColumns(0) = table.Columns("id") |
table.PrimaryKey = PrimaryKeyColumns |
ds = New DataSet() |
ds.Tables.Add(table) |
Dim i As Integer |
For i = 0 To 4 |
row = table.NewRow() |
row("id") = i |
row("Item") = "This is Item " + i.ToString() |
table.Rows.Add(row) |
Next i |
RadPanelBar1.DataSource = ds |
RadPanelBar1.DataFieldID = "id" |
RadPanelBar1.DataFieldParentID = Nothing |
RadPanelBar1.DataTextField = "Item" |
RadPanelBar1.DataValueField = "id" |
RadPanelBar1.ExpandMode = Telerik.Web.UI.PanelBarExpandMode.SingleExpandedItem |
RadPanelBar1.DataBind() |
End Sub |
Private Sub RadPanelBar1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadPanelBarEventArgs) Handles RadPanelBar1.ItemDataBound |
Dim thisItem As RadPanelItem = e.Item |
Dim thisGrid As RadGrid = MakeMyGrid |
Dim thisNewItem As New RadPanelItem |
thisNewItem.Controls.Add(thisGrid) |
thisItem.Items.Add(thisNewItem) |
End Sub |
Function MakeMyGrid() As RadGrid |
Dim thisGrid As New RadGrid |
thisGrid.DataSource = ds |
' Must do ALL grid setup in here in some fashion. |
'thisGrid.Columns.Add(New gridcol |
thisGrid.DataBind() |
Return thisGrid |
End Function |
End Class |

I ended up going back and just using a databound accordion with databound gridviews in the template.
Display was easy enough, but the imagebuttons inside the grid were only firing every OTHER click. For the failed clicks, they posted back, but no event fired at the server.
After quite a bit of looking around, I found out that the latest version of the ajax tookit does NOT have the latest code. There is a bugfix on codeplex for the accordion control, which fixed my click/event issues. From MAY, but it wasn't in the August release.
Not sure if this will help you any or not.
I ended up skipping the panelbar, as it is just too complex to use for databinding purposes for what I needed to get done.
( The panelbar wanted to create a line for the databound row, and a NEW line for the itemtemplate. I need one line total for the "child" rows. )