PDA

View Full Version : ext.Accordion in code behind



filip.beunens
Jan 20, 2010, 7:38 AM
Hi,

i made a webusercontrol that builds a user related Accordion menu from a database, it works fine but I can't figure out how I could open the first panel by default after building.

A second thing I can't figure out is how I can convert the String value of my oMenuItem.icon to show the correct Icon

Something like mPanel.Icon = HOW DO I DO CAST THIS( oMenuItem.Icon )

My code :



Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim oMenuStructuur As New List(Of Menu)
oMenuStructuur = MenuDA.GetMenuVoorUser(Context.User.Identity.Name)

' Build menu from table

Dim mAccor = New ext.Accordion
mAccor.ID = "Accordion"
Me.Controls.Add(mAccor)
For Each oMenuItem As Menu In oMenuStructuur
If oMenuItem.Depth = 0 Then
mPanel = New ext.MenuPanel
mPanel.Title = oMenuItem.Naam
mPanel.ID = "MenuPanel" & oMenuItem.Sort
'mPanel.Icon = HOW DO I DO CAST THIS oMenuItem.Icon
mPanel.Border = False
mPanel.Collapse()
mAccor.Items.Add(mPanel)
ElseIf oMenuItem.Depth = 1 Then
Dim mitem = New ext.MenuItem
mitem.ID = "Menuitem" & oMenuItem.Sort
mitem.Text = oMenuItem.Naam
mitem.Icon = ext.Icon.BulletRight
mitem.Listeners.Click.Handler = "#{CenterPanel}.load({url:'" & oMenuItem.Href & "', mode:'iframe', showMask:true, maskMsg:'Page " & oMenuItem.Name & " is loading...'});"
mPanel.Menu.Items.Add(mitem)
End If
Next
End Sub


Thanks on advance
Filip

Vladimir
Jan 20, 2010, 7:53 AM
Hi,

1. Try ActiveIndex property of the AccordionLayout container or ExpandPanel method of the AccordionLayout


2. I am not sure that cast is required because menu item Icon property has the same type with panel Icon property

filip.beunens
Jan 20, 2010, 9:10 AM
Thanks Vladsch,

I'll try your advice, concerning the icon the problem I have is that in the databases i have a string value with the name of the icon for example "bulletright" in the ext libary the icon is a ext.Icon.BulletRight object.

So i have to search and define a ext.icon when I ony know his name. Only don't know how to do it.

Thanks

Vladimir
Jan 20, 2010, 9:14 AM
Hi,

Please see
http://msdn.microsoft.com/en-us/library/system.enum.parse.aspx

filip.beunens
Jan 20, 2010, 3:47 PM
Thanks for the link Vladsh,

This VB code did the job nicely :





Dim Icon As ext.Icon = [Enum].Parse(GetType(ext.Icon), oMenuItem.Icon)
mPanel.Icon = Icon