ExpandMode="SingleExpandedItem" with always expanded RadItem

3 posts, 0 answers
  1. Achim
    Achim avatar
    13 posts
    Member since:
    Sep 2007

    Posted 29 Sep 2009 Link to this post

    Hello

    i am trying to make a RadPanelBar with a behaviour like with ExpandMode="SingleExpandedItem" for all items except the last..
    So the last RadItem should always be expanded and the other RadItems should behave like with SingleExpandedItem mode.
    Can you please tell me if this possible?

    Thanks
    Achim
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Sep 2009 Link to this post

    Hi Achim,

    I have achieved same bahaviour by setting the ExpandMode="SingleExpandedItem" for RadPanelBar and by setting the properties  Expanded="True" and PreventCollapse="True" for last RadPanelbarItem. Give a try with following code:

    ASPX:
     
    <telerik:RadPanelBar ID="RadPanelBar1" runat="server" ExpandMode="SingleExpandedItem"
        <Items> 
            . . . 
            <telerik:RadPanelItem runat="server" Expanded="True" PreventCollapse="True" Text="Last Root RadPanelItem"
                <Items> 
                   . . . 
                </Items> 
            </telerik:RadPanelItem> 
        </Items> 
    </telerik:RadPanelBar> 

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Achim
    Achim avatar
    13 posts
    Member since:
    Sep 2007

    Posted 30 Sep 2009 Link to this post

    Hi Shinu,

    thanks for the solution how to do this, glad to not have to write any javascript for this.
    In my situation i have bound the RadPanelBar to a XmlSitemapProvider and have no hardcoded RadItems..
    So i tried to set the properties in codebehind in various events like ItemDataBound-Event with code like:
        protected void RadPanelbar1_ItemCreated(object sender, Telerik.Web.UI.RadPanelBarEventArgs e) 
        { 
            if (e.Item.Text.ToLower().Trim().Equals("last item"))
            { 
                e.Item.Expanded = true
                e.Item.PreventCollapse = true
            } 
        }

    Now problem here is on first load the item dont get expanded... I can expand it client-side and it keeps expanded while expanding/collapsing other items.. But as soon i do a full postback it will be collapsed again like on first load...
    i am thinking of small javascript to expand client side after postback, but want to ask first if you have better idea?

    Thanks
    Achim
Back to Top