Panel items won't expand or collapse

4 posts, 0 answers
  1. Paul
    Paul avatar
    76 posts
    Member since:
    Feb 2008

    Posted 18 May 2010 Link to this post

    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  
        } 
  2. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 20 May 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Paul
    Paul avatar
    76 posts
    Member since:
    Feb 2008

    Posted 20 May 2010 Link to this post

    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);   
     

  5. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 21 May 2010 Link to this post

    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.
Back to Top