Databound PanelBar will not collapse

4 posts, 0 answers
  1. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jan 2011

    Posted 29 Jan 2011 Link to this post

    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
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 01 Feb 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jan 2011

    Posted 01 Feb 2011 Link to this post

    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.
  5. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jan 2011

    Posted 01 Feb 2011 Link to this post

    I have managed to use jQuery to achieve the functionality I was looking for. Thanks anyway.
Back to Top