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

How do I collapse panel bar with server code

3 Answers 134 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Tomica
Top achievements
Rank 2
Tomica asked on 06 May 2008, 02:49 AM
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.

3 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 06 May 2008, 09:16 AM
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
0
Tomica
Top achievements
Rank 2
answered on 08 May 2008, 01:47 AM

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.

0
Accepted
Rosi
Telerik team
answered on 10 May 2008, 11:32 AM
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
Tags
PanelBar
Asked by
Tomica
Top achievements
Rank 2
Answers by
Rosi
Telerik team
Tomica
Top achievements
Rank 2
Share this question
or