ext.Accordion in code behind

  1. #1

    ext.Accordion in code behind

    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
  2. #2

    RE: ext.Accordion in code behind

    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
  3. #3

    RE: ext.Accordion in code behind


    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
  4. #4

    RE: ext.Accordion in code behind

  5. #5

    RE: ext.Accordion in code behind


    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

Similar Threads

  1. Replies: 2
    Last Post: Feb 01, 2012, 6:56 AM
  2. Accordion Problem
    By Egale in forum 1.x Help
    Replies: 2
    Last Post: May 06, 2011, 6:25 PM
  3. Replies: 5
    Last Post: Nov 11, 2010, 7:33 PM
  4. Replies: 2
    Last Post: Apr 25, 2010, 2:15 AM
  5. Stateful accordion
    By Rod in forum 1.x Help
    Replies: 3
    Last Post: Nov 24, 2008, 10:46 AM

Posting Permissions