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

Panel items won't expand or collapse

3 Answers 130 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 18 May 2010, 04:50 PM
A bit of background: I had created a user control (ascx) that contained a RadPanelBar containing two RadPanelItems each with their own item templates with various other controls. I have everything working just as I like it.

I am now in the process of converting that control into a server control and ran into a problem. I followed an example provided in the documentation that explained how to programmatically add a RadPanelBar with ItemTemplates (Found in the docs here: Controls/RadPanelBar/Templates/Adding Templates at run-time) and I was able to display the panel bar exactly as it describes, but the panels won't expand or collapse.

What am I missing?

Here's my code so far:
[ToolboxData("<{0}:CustNameSidErpDeptProd runat=server></{0}:CustNameSidErpDeptProd>")]  
    public class CustNameSidErpDeptProd : WebControl  
    {
        #region Member Variables  
 
        private readonly RadPanelBar _radPanelBar = new RadPanelBar();  
        private readonly RadPanelItem _rpi = new RadPanelItem("PanelItem1");
        #endregion  
 
        #region Properties
        #endregion  
 
        #region Overrides  
 
        protected override void OnInit(EventArgs e)  
        {  
            _radPanelBar.AllowCollapseAllItems = true;  
            _radPanelBar.ExpandMode = PanelBarExpandMode.SingleExpandedItem;  
            _radPanelBar.EnableViewState = true;  
            _radPanelBar.Width = Unit.Percentage(100);  
            _rpi.ItemTemplate = new TextBoxTemplate();  
            base.OnInit(e);  
        }  
        protected override void OnLoad(EventArgs e)  
        {  
            _radPanelBar.Items.Add(_rpi);  
            _radPanelBar.Items.Add(new RadPanelItem("PanelItem2"));  
            _radPanelBar.DataBind();  
            Controls.Add(_radPanelBar);  
        }
        #endregion  
 
        #region Public Methods
        #endregion  
 
        #region Private Methods
        
        #endregion  
    } 

3 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 20 May 2010, 02:57 PM
Hello Paul,

If you are unable to expand and collapse items, then you may have a JavaScript error in the page. If this is the case, the entire JavaScript on the page won't work.
Please, check this out and if the problem persists, please open a support ticket and send me a simple project reproducing this issue.

Hope this is helpful!


Regards,
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.
0
Paul
Top achievements
Rank 1
answered on 20 May 2010, 03:52 PM
Hi Nikolay,

I did end up opening a support ticket (because the forums didn't seem to be working for new posts at the time) and then shortly there after resolved the issue myself.

For everyone's benefit here is what I did to resolve it:

My working code:
[ToolboxData("<{0}:CustNameSidErpDeptProd runat=server></{0}:CustNameSidErpDeptProd>")]  
    public class CustNameSidErpDeptProd : WebControl  
    {
        #region Member Variables  
 
        private readonly RadPanelBar _radPanelBar = new RadPanelBar();  
        private readonly RadPanelItem _rpi = new RadPanelItem("PanelItem1");
        #endregion  
 
        #region Properties
        #endregion  
 
        #region Overrides  
 
        protected override void OnInit(EventArgs e)  
        {  
            _radPanelBar.AllowCollapseAllItems = true;  
            _radPanelBar.ExpandMode = PanelBarExpandMode.SingleExpandedItem;  
            _radPanelBar.EnableViewState = true;  
            _radPanelBar.Width = Unit.Percentage(100);  
            _rpi.ItemTemplate = new TextBoxTemplate();  
            base.OnInit(e);  
        }  
        protected override void OnLoad(EventArgs e)  
        {  
            var rpi = new RadPanelItem("Test");  
            rpi.Items.Add(_rpi);  
 
            _radPanelBar.Items.Add(rpi);  
            _radPanelBar.Items.Add(new RadPanelItem("PanelItem2"));  
            _radPanelBar.DataBind();  
              
            Controls.Add(_radPanelBar);  
        }
        #endregion  
 
        #region Public Methods
        #endregion  
 
        #region Private Methods
        
        #endregion  
    } 

The difference was first creating a new RadPanelItem, then adding my templated item to that and finally to the main panelbar.
var rpi = new RadPanelItem("Test");     
rpi.Items.Add(_rpi);     
    
_radPanelBar.Items.Add(rpi);   
 

0
Nikolay Tsenkov
Telerik team
answered on 21 May 2010, 08:34 AM
Hello Paul,

Glad that you resolved your problem!

Sorry for the inconvenience if the forums didn't worked for you at the time, although I didn't received any notification by other users. We will check this out and make sure if there is a problem to resolve it.


Regards,
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.
Tags
PanelBar
Asked by
Paul
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Paul
Top achievements
Rank 1
Share this question
or