How do I collapse panel bar with server code

4 posts, 1 answers
  1. Tomica
    Tomica avatar
    147 posts
    Member since:
    Apr 2008

    Posted 05 May 2008 Link to this post

    I am new to RADPanelBar and a bit puzzled about interactions on the server.

    In the case where there is no data for the panel item, I want to force it closed and disable it, and this is done on the server:

    Me.Next_PanelBar.Enabled = False

    Me.Next_PanelBar.Items(0).Items(0).Expanded = False

    Me.Next_PanelBar.Items(0).Items(0).Text = "yadda"


    The panel is disabled, the text changes to "yadda', but it does not collapse.

    I'm guessing that there is a distinction between "properties" that can be modified, vs. "methods" that need to be invoked. If so, how?

    Note: panel behaves properly when enabled, end-user can expand/collapse with no problem.

  2. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 06 May 2008 Link to this post

    Hello Tom,

    Please find attached a project illustrating that everything worked as expected at our side. If this does not help you, please open a support ticket and send us a running project illustrating the problem to test it locally.

    Regards,
    Rosi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tomica
    Tomica avatar
    147 posts
    Member since:
    Apr 2008

    Posted 07 May 2008 Link to this post

    Yes, the attached project works fine, as delivered.

    However, if you change PersistStateInCookie to "true", the then the code does nothing.

    In my application, I use the PanelBar to expose certain additional information that the user might want to see as they are browsing, hence persistence is of value. The panel sticks to whatever setting they choose, expanded or collapsed.

    My intention is to provide a button that expands or collapses all of the panels on the form, as the user can do for all six on the page.

    This works if persistance is turned off, but essentially, I want to change the state of the panels and have those changes persist until the user selects another option, or manually expands/contracts any of the panels.

    I tried turning persistence off, doing the collapse, then setting persistence back on, all in the server code tied to the button, but this doesn't seem to help. The last line seems to override, or restore persistence before the panels are contracted.

    RadPanelBar1.PersistStateInCookie =

    False

    RadPanelBar1.Items(0).Expanded = False

    RadPanelBar1.PersistStateInCookie =

    True

    I'm thinking that I will need to explore doing this via client code.

  5. Answer
    Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 10 May 2008 Link to this post

    Hi Tom,

    You can collapse the item after the PersistStateFromCookie logic is performed. If RadPanelBar's items are defined inline you can do this in PreRender event of RadPanelBar:

    Protected Sub RadPanelBar1_PreRender(ByVal sender As ObjectByVal e As EventArgs)  
                                  
    RadPanelBar1.Items(0).Expanded = False 
              
    End Sub 

    If the items are bound from a datasource you can use DataBound event of RadPanelBar:
    Protected Sub RadPanelbar1_DataBound(ByVal sender As ObjectByVal e As System.EventArgs) Handles RadPanelbar1.DataBound  
     
     RadPanelBar1.Items(0).Expanded = False 
    End Sub 


    Regards,
    Rosi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top