Expanding DataBound items with ItemTemplate

2 posts, 0 answers
  1. ile
    ile avatar
    5 posts
    Member since:
    Oct 2006

    Posted 14 Oct 2010 Link to this post


    I'm using RadPanelBar Q1 2010 SP2. and having following scenario: I'm binding the top level items to List<T>. Then under each item I'd like to add ItemTemplate with quite a lot of controls inside (TextBoxes, GridView, etc.) so adding them dynamically in .cs isn't an option. Problem is that following declarative syntax displays right but doesn't expand :

    <telerik:RadPanelBar ID="RadPanelBar1" runat="server" Skin="Vista" ExpandMode="FullExpandedItem" DataFieldParentID="Id" DataTextField="Name">
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

    ObjectiveCollection objectives = user.Objectives;
    RadPanelBar1.DataSource = objectives;
  2. Nikolay Tsenkov
    Nikolay Tsenkov avatar
    734 posts

    Posted 19 Oct 2010 Link to this post

    Hello ile,

    The right way to implement this requirement is to create the templates in the code-behind as classes implementing the ITemplate interface. Here is a nice article that should give you an idea: http://www.telerik.com/help/aspnet-ajax/tree_templatesruntime.html

    After you implement that you can create a handler to the TemplateNeeded event of the panelBar (it will be thrown for every item that is created from the dataSource, separately) and there you will have the item (in the event arguments), so you can decide which template should it take. Here is a nice reference for this event: http://www.telerik.com/help/aspnet-ajax/telerik.web.ui-telerik.web.ui.radpanelbar-templateneeded_ev.html

    Hope this is helpful for you!

    Nikolay Tsenkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top