B4J Tutorial [BANanoWebix] Lesson 16 - The Sidebar

Discussion in 'B4J Tutorials' started by Mashiane, Jun 25, 2019.

  1. Mashiane

    Mashiane Expert Licensed User


    Well this is one of my favourate elements.


    First lets add the toolbar in a row with badges and then after that we add the sidebar with the various icons. The structure of the menu has been borrowed greatly from the WixMenu element.

    The ToolBar

    We initialize a menu and add buttons to it. The first menu item, being an icon, we add an event to it so that we can toggle the sidebar.

    Dim R1 As WixRow
    'add toolbar
        Dim tblBar As WixToolBar
    "menuopen").SetIcon("mdi mdi-menu").SetClick(BANano.CallBack(Me, "OpenMenu"Null)).Pop
    "heading").SetLabel("Lesson 16: Side Bar").Pop
    "").SetIcon("mdi mdi-comment").SetBadge("4").pop
    "").SetIcon("mdi mdi-bell").SetBadge("10").Pop

    When the menu icon is clicked, it calls the callback to toggle the sidebar.

    Sub OpenMenu()
    End Sub
    The SideBar

    The sidebar items are created in such a way that one method is used, called .AddItem that also accepts the parent 'id' of the owner item.

    Dim sm As WixSideBar
        sm.AddItem("""dashboard""Dashboards","","mdi mdi-view-dashboard""2","")
    "dashboard""dashboard1""Dashboard 1","","mdi mdi-view-dashboard""","")
    "dashboard""dashboard2""Dashboard 2","","mdi mdi-view-dashboard""","")
        sm.AddItem("""layouts""Layouts""""mdi mdi-view-column""","")
    "layouts""accordions""Accordions""""mdi mdi-view-column""","")
    "layouts""portlets""Portlets""""mdi mdi-view-column""","")
        sm.AddItem("""tables""Data Tables""""mdi mdi-table""","")
    """uis""UI Components""""mdi mdi-puzzle""","")
        Dim R2 As WixRow
        Dim meid As Map
    "sm", BANano.CallBack(Me, "itemClick"Array(meid)))
    The items are added to the sidebar and the sidebar added to the 2nd row of our page as the 1st row has the toolbar.

    You might have picked that this is using 'mdi' i.e Material Design Icons, these are added via.

    Easily for the sidebar we have added the itemClick method and just message the selected key out.

    Sub itemClick(meID As String)
    End Sub
    As you might have noted, there is a consistency of how things are being done like methods, ids, values etc.
    joulongleu and José J. Aguilar like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice