B4J Tutorial [BANanoWebix] Lesson 4: Carousels, MultiView & TabView

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

  1. Mashiane

    Mashiane Expert Licensed User


    This lesson is about the 3 layout elements being the carousel, multiview and the tabview. Each of the elements here are added in each row of our page.

    Carousel: We will create a carousel with three sliders. We will use css to set the background and color of each slide.


    Dim c As WixCarousel
    'create slides
        Dim sld1 As WixElement
        Dim sld2 As WixElement
        Dim sld3 As WixElement
    "Mary Ann")
    Each slide in the carousel is added to the columns collection in the carousel. Whilst we can use .AddColumns, there is also an additional methid called .AddSlide added to easily add each slide.

    To set the css element of each slide object, we have used the SetStyle method to change the background color and color of the slide. As the underlying elements are HTML elements, one can use any css combination they way for any WixElement.

    After all the slides are added, we add the carousel to the rows of the page.
  2. Mashiane

    Mashiane Expert Licensed User


    For the multiview, we use a Segmented element with a multiview property turned to true for this example. As this acts like a tab view element, there are two sections to update for this, the header of each tab and then the linked child for that header. The child contents of each tab are stored in the Cells collection of the element.


    'add segment
        Dim sg As WixSegmented
    "rick""Rick","Alcoholic<br>Science Genius<br>Father of Beth")
    "morty""Morty","14 years old<br>Mortiest Morty<br>Sidekick")
    As this is a segmented element, we add options to it for each element header, e.g. Rick and Morty and then some details for each. There are two calls to made to create the multiview segmented control, one to add the structure of the element to the page and the second part to add the children Cells with AddRowsCells.

    These are both added to the Rows collection of the page and linked together.
  3. Mashiane

    Mashiane Expert Licensed User


    The tabview element is the actual tabs based view.


    Dim tb As WixTabView
    "","Entry","Some form controls here",CreateMap("css":"entry"))
    "","Results","Some results of data entry here",CreateMap("css":"results"))
    As noted here, there is a map to set the css for each element added to the tab. Whilst the actual css class is not included here, we are just demonstrating how one can apply css classes to the elements of the tabview.

  4. Mashiane

    Mashiane Expert Licensed User

    Lesson 4 Update

    The multi-view component has been rewritten for ease of implementation. Previosly this was included as part of the segment control however it is a stand alone component and is linked to the segment via unique id numbers.


    For example, here we create a page and add a row.

    Sub Init(pgContainer As String)
    "wp", pgContainer).SetHeader("Lesson 4.2: MultiView").SetResponsive("master").SetTypeClean("")
        Dim R1 As WixRow
        Dim seg As WixSegmented
        Dim mv As WixMultiView
        Dim v1 As WixElement
    "view1").SetTemplate("Form Content")
        Dim v2 As WixElement
    "view2").Settemplate("<i>Info about the Form</i>")
    End Sub
    We then create a segmented control and a multiview. We add two options called view1 and view2 to the segment control. On the multiview we also add items called view1 and view2 so that this is linked to the segmented component.

    One can show a multi-view item by calling page.show("view2") and to hide it call pg.Hide("view1") via code.

    Going back from in a multiview is achived by calling pg.Back("mymv")

    A multi-view is useful for large applications as it enables 1 screen to be shown at a time.
    Johan Hormaza, joulongleu and ThRuST 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