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

PanelBar Expand items

6 Answers 107 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 07 Sep 2012, 03:22 AM
Is there a way to control what items will be expended when panel bar is first loaded?
By default it seams to collapse everything.
I would like to have the second level expended. 

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Sep 2012, 04:21 AM
Hi Andrew,

Try setting Expanded property of RadPanelItem to true to achieve your scenario.Here is the sample code that I tried.

ASPX:
<telerik:RadPanelBar ID="RadPanelBar1" runat="server">
  <Items>
   <telerik:RadPanelItem Text="RadPanelItem1">
     <Items>
         ................
     </Items>
   </telerik:RadPanelItem>
   <telerik:RadPanelItem Text="RadPanelItem2" Expanded="true">
     <Items>
         ................
     </Items>
   </telerik:RadPanelItem>
   <telerik:RadPanelItem Text="RadPanelItem3">
     <Items>
         ................
     </Items>
   </telerik:RadPanelItem>
  </Items>
</telerik:RadPanelBar>

Hope this helps.

Regards,
Princy.

0
Andrew
Top achievements
Rank 1
answered on 07 Sep 2012, 09:48 AM
Can't do that the items are created dynamically by binding the panelbar to a datasource. Which is actually a sitemap from sitefinity.
0
Princy
Top achievements
Rank 2
answered on 07 Sep 2012, 10:07 AM
Hi Andrew,

Try the following code to achieve your scenario.

C#:
RadPanelBar1.Items[1].Expanded = true;

Hope this helps.

Regards,
Princy.
0
Andrew
Top achievements
Rank 1
answered on 09 Sep 2012, 05:24 AM
That worked.
I put in in the ItemBound Event:
protected void RadPanelBar1_DataBound(object sender, EventArgs e)
        {
            foreach (RadPanelItem myItem in (((RadPanelBar)sender).Items))
            {
                myItem.Expanded = true;
            }
        }
Expends only the first level which works well for me.

I would in fact like to disable to possibility of the end user collapsing that level.

Is there a property on the item i can set to do so?
0
Accepted
Princy
Top achievements
Rank 2
answered on 10 Sep 2012, 06:59 AM
Hi Andrew,

Try setting PreventCollapse property of RadPanelItem to true achieve your scenario.

C#:
foreach (RadPanelItem myItem in (RadPanelBar1.Items))
    {
     myItem.Expanded = true;
     myItem.PreventCollapse = true;
    }

Regards,
Princy.
0
Andrew
Top achievements
Rank 1
answered on 10 Sep 2012, 09:21 AM
Thanks that works.
Tags
PanelBar
Asked by
Andrew
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Andrew
Top achievements
Rank 1
Share this question
or