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

Databound PanelBar will not collapse

3 Answers 51 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 30 Jan 2011, 02:10 AM
Hi...

Kinda new to the PanelBar and I am trying to do something specific with it that I am not finding on the forums.

I have a PanelBar which I am databinding in the code behind.

Each Item will have a repeater inside it so I have the following code
<telerik:RadPanelBar ID="RadPanelBar1" runat="server"  ExpandMode="FullExpandedItem">
    <ExpandAnimation Type="None" />
    <CollapseAnimation Type="None" />
    <ItemTemplate>
        <asp:Repeater ID="PremisesRepeater" runat="server">
            <ItemTemplate>
                <%--..some user control--%>
            </ItemTemplate>
        </asp:Repeater>
    </ItemTemplate>
</telerik:RadPanelBar>

Bound like this.

RadPanelBar1.DataSource = MyCustomer.MyBusinesses;
RadPanelBar1.DataTextField = "Id";
RadPanelBar1.DataValueField = "Id";
RadPanelBar1.DataBind();

The problem is that once this is databound, the PanelBar doesnt collapse any items at all. Everything is expanded and the repeater and it's contents are shown for all items. Items will not collapse when the header is clicked on.

Am I missing something? I would like to use this control specifically for the expand/collapse functionality.

Kind Regards,
Andrew

3 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 01 Feb 2011, 06:01 PM
Hi Andrew,

In order to be able to expand the items in the PanelBar I would suggest that you used ContentTemplate instead of ItemTemplate (see the difference here). However, since you can not set it globally for the PanelBar and only for the Items you could add the template at a run-time and use it on the server-side.
protected void RadPanelBar2_TemplateNeeded(object sender, Telerik.Web.UI.RadPanelBarEventArgs e)
{
    e.Item.ContentTemplate = new TextBoxTemplate();
}
 
And hook it on the PanelBar like this:
<telerik:RadPanelBar ID="RadPanelBar2" runat="server" ontemplateneeded="RadPanelBar2_TemplateNeeded">
    <ExpandAnimation Type="None" />
    <CollapseAnimation Type="None" />
</telerik:RadPanelBar>

Greetings,
Kate
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Andrew
Top achievements
Rank 1
answered on 01 Feb 2011, 09:36 PM
That just seems like a bit of a long-winded way of doing something which I feel should come out of the box.

Do you have an example of how to implement this with a web user control (.ascx)?

I appreciate the help.
0
Andrew
Top achievements
Rank 1
answered on 01 Feb 2011, 11:01 PM
I have managed to use jQuery to achieve the functionality I was looking for. Thanks anyway.
Tags
PanelBar
Asked by
Andrew
Top achievements
Rank 1
Answers by
Kate
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or