Unable to collapse PanelBar

6 posts, 0 answers
  1. Jo
    Jo avatar
    7 posts
    Member since:
    Dec 2010

    Posted 11 Feb 2011 Link to this post

    I have been trying for a couple of days now to get my PanelBar working with databound items, where the item template consists of a user control.  Here is my code:

    <telerik:RadPanelBar runat="server" ID="pbSupplierAgreements" AllowCollapseAllItems="true"                 OnItemDataBound="pbSupplierAgreements_ItemDataBound" ExpandMode="SingleExpandedItem"                        Width="100%" DataValueField="ID" DataTextField="SupplierCode" DataTextFormatString="Supplier: {0}">
      <ItemTemplate>
        <telerik:RadPanelItem>
          <Items>
            <telerik:RadPanelItem>
              <ItemTemplate>
                <e:SupplierAgreementView ID="SupplierView" runat="server" />
              </ItemTemplate>
            </telerik:RadPanelItem>
          </Items>
        </telerik:RadPanelItem>
      </ItemTemplate>
    </telerik:RadPanelBar>

    When the OnItemDataBound is called I bind the data item to the SupplierAgreementView control.

    The problem is that this renders the control and data ok , but the panel bar items are all expanded but I can't collapse them and there is no collapse button on the panel bar item headers.

    Please help!
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 11 Feb 2011 Link to this post

    Hello Jo,

    The reason for this is that you're using templates on the root items.

    You should either use item template on the child items or content template on the root items as demonstrated in the example here.

    Regards,
    Yana
    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. Jo
    Jo avatar
    7 posts
    Member since:
    Dec 2010

    Posted 11 Feb 2011 Link to this post

    Hello Yana,

    Thanks for replying so promptly!  I have tried changing my items as you suggested but I must be doing something wrong.  I have removed by user control and just put a label in the content template to simplify things.  Here is my code now:

    <telerik:RadPanelBar runat="server" ID="pbSupplierAgreements" AllowCollapseAllItems="true" OnItemDataBound="pbSupplierAgreements_ItemDataBound" ExpandMode="SingleExpandedItem" Width="100%" DataValueField="ID">
      <Items>
        <telerik:RadPanelItem>
          <HeaderTemplate>
            Supplier
          </HeaderTemplate>
          <ContentTemplate>
            <telerik:RadPanelItem>
              <ItemTemplate>
                <asp:Label ID="lblSupplierContact" runat="server" Text='<%# Eval("SupplierContact") %>'></asp:Label>
              </ItemTemplate>
            </telerik:RadPanelItem>
          </ContentTemplate>
        </telerik:RadPanelItem>
      </Items>
    </telerik:RadPanelBar>


    In my code behind I am setting the data source of the panel to be an IList<myComplexType> and calling DataBind().  But when the page loads I just see two collapsed items, with the name of the type as the header.  The label is not rendered either and I can't expand the items.
  5. Chris
    Chris avatar
    4 posts
    Member since:
    Dec 2010

    Posted 14 Feb 2011 Link to this post

    Hi

    I'm having pretty much the same issue. Here is my code:
    <e:EnumDataSource ID="EnumSource" runat="server" EnumerationTypeName="ExternalContractSupportAPI.Entities.EcsStatus" />
     
        <t:RadPanelBar ID="TermsPanelBar" runat="server" DataTextField="Name" DataSourceID="EnumSource" ExpandMode="SingleExpandedItem">
            <Items>
                <t:RadPanelItem Expanded="true">
                    <ContentTemplate>
                        OK: <%#Eval("Name")%>
                    </ContentTemplate>
                </t:RadPanelItem>
            </Items>
        </t:RadPanelBar>

    The result looks like the attached image: the headers populate correctly but no content is generated.

    Any help would be appreciated!

    Chris
  6. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 16 Feb 2011 Link to this post

    Hello Jo,

    You shouldn't place RadPanelItem in the content template - you can directly place the controls:

    <telerik:RadPanelBar runat="server" ID="pbSupplierAgreements" AllowCollapseAllItems="true"
        OnItemDataBound="pbSupplierAgreements_ItemDataBound" ExpandMode="SingleExpandedItem"
        Width="100%" DataValueField="ID">
        <Items>
            <telerik:RadPanelItem>
                <HeaderTemplate>
                    Supplier
                </HeaderTemplate>
                <ContentTemplate>
                    <asp:Label ID="lblSupplierContact" runat="server" Text='<%# Eval("SupplierContact") %>'></asp:Label>                     
                </ContentTemplate>
            </telerik:RadPanelItem>
        </Items>
    </telerik:RadPanelBar>


    Best wishes,
    Yana
    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.
  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 16 Feb 2011 Link to this post

    Hi Chris,

    You cannot set content template globally when the panelbar is databound - in this case the template should be set at runtime. I've attached a simple page to demonstrate the approach, please download it and give it a try.

    Regards,
    Yana
    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017