Adding a Button-Toggle to a ControlBar

Description

You can add a Button-Toggle to a ControlBar. Toggle buttons can either be two-state (switching between a true and a false state), or multi-state (each click advances to the next button state). The video shows how the state of a Button-Toggle is used to control what action a button performs when clicked.

A toggle button in the top right determines the direction to move through a list control.
A toggle button in the top right determines the direction to move through a list control.

For a visual explanation on how the state of a Button-Toggle is used to control what action a button performs when clicked follow the guide below or watch this video:

Adding a Button-Toggle to a ControlBar

In this video we show how you can add a Button-Toggle to a ControlBar. Toggle buttons can either be two-state (switching between a true and a false state), or multi-state (each click advances to the next button state).

The video shows how the state of a Button-Toggle is used to control what action a button performs when clicked.

Download Component

2016-09-14

Create a Component with a ControlBar and List

  1. In the UX Builder open the Properties page. In the UX Properties section click the button next to the 'Style name' property.

    Tog
  2. From the 'Location' menu select 'System' and from the style options select the 'Alpha' style. Click OK.

    Tog2
  3. Open the UX Controls page and check the 'Mobile' checkbox.

    Tog3
  4. Open the Panels menu and select the [Panel Card] option to add a panel card to the component tree.

    Tog4
  5. Highlight the panel card. Open the 'Containers' menu and click on the [Container] option.

    Tog5
  6. From the Container Type list select 'PanelHeader' and click the 'Insert After' button.

    Tog6
  7. Highlight the panel header. Open the 'Other Controls' menu and select the [ControlBar] option to add a control-bar to the panel header.

    Tog7
  8. Highlight [PanelHeader End: PANELHEADER_1]. Open the Data Controls menu and click [List] to add a list control underneath the panel header.

    Tog8
  9. Highlight the list control. In the properties list on the right, under List Properties, click the button next to the 'List properties' property to open the List Builder.

    Tog9
  10. In the List Builder open the Data Source Pane. Set the 'Data Source Type' to SQL.

    Tog10
  11. Click on the button next to the Connection String property, in the SQL Data Source section.

    Tog11
  12. Set the 'Table name' property to the 'Customers table.

    Tog12
  13. Click the button next to the 'Field list' property and select the 'ContactName' and 'City fields'.

    Tog13
  14. Open the List Layout pane. Use the blue > arrow to move the ContactName and City fields from the Available Fields list to the 'Columns in List' area. Click OK to close the list builder.

    Tog14
  15. The component tree should now look like this:

    Tog15

Add a Button-Toggle that Navigates the List

  1. Highlight [ControlBar:CONTROLBAR_1]. In the Properties list under ControlBar Properties click the 'ControlBar properties' property to open the ControlBar Builder.

    Tog16
  2. In the ControlBar Builder open the 'Items' pane and click the 'Add ControlBar Item' button.

    Tog17
  3. Select 'button-toggle' option from the Item Type choices and click OK.

    Tog18
  4. In the ControlBar Item Properties menu go to the 'Button Settings for Button-Toggle' section. Set the 'Button layout' property to 'Image only'.

    Tog19
  5. In the same section click the button next to the 'Icon' property.

    Tog20
  6. In the 'Specify Image' dialog select 'SVG Icon' from the list of radio button choices. Hit the 'Select' button.

    Tog21
  7. Click on the 'arrowDown' SVG icon to select it and click OK and OK again.

    Tog22
  8. Back in the 'Items' pane click the button next to the 'Pressed icon' property. This should be just below to Icon property.

    Tog23
  9. Choose the SVG Icon property and click 'Select'.

    Tog24
  10. Click on the 'arrowUp' icon and click OK and OK again.

    Tog25
  11. In the 'Items' pane scroll up the ControlBar Item Properties list to the 'Button-Toggle Settings'. Make sure the Type property is set to 'Two-State'.

    Tog26
  12. Next to the 'Data variable' property define a new data variable called 'toggleState'.

    Tog27
  13. Open the 'Actions' pane and click on the 'Add Action' button to create a new action. Give the action the name 'next'.

    Tog28
  14. Add the following Javascript to define the action:

    var lObj = {dialog.object}.getControl('list1');
    if(!this.data.toggleState) {
        lObj.navigate('next');
    } else {
        lObj.navigate('prev');
    }
    Tog29
  15. Open the 'Items' pane again. Click the 'Add ControlBar Item' button.

    Tog30
  16. From the Item Type choices select 'button' and click OK.

    Tog31
  17. Highlight the button item. In the ControlBar Item Properties list, under 'Item Actions', hit the button next to the 'Click' property.

    Tog32
  18. Select the 'next' action that you just defined.

    Tog33
  19. Scroll down the ControlBar Item Properties list to the Button Settings. Change the 'Button layout' property to be 'Image followed by text'.

    Tog34
  20. Click the button next to the Icon property.

    Tog35
  21. In the Specify Image dialog select the 'SVG Icon' option and click 'Select'.

    Tog36
  22. Select the 'arrowsVertical' icon and click OK and OK again.

    Tog37
  23. Towards the bottom of the Button Settings section set the 'Button text' property to read 'Move'.

    Tog38
  24. Open the ControlBar Layout pane. Click the 'Add Layout' button. Give the layout a name like Layout1 and click OK.

    Tog39
  25. Click the 'Add Line' button

    Tog40
  26. Click the 'Add' button under the Before section, highlight the button item you defined, and click OK.

    Tog41
  27. Add the 'button-toggle' item to the 'After:' section by clicking the 'Add' button, highlighting the 'button-toggle' item and clicking OK. Click OK to close the Edit Layout Line dialog.

    Tog42
  28. Click OK again to close the ControlBar Builder. Run the component in Live Preview

    Tog43
  29. Click on a row in the list and press the 'Move' button. You should be able to move down the list control.

    Tog44
  30. Now try pressing the button-toggle button. The icon should change to point up. Click on the Move button again and you should be able to move up through the rows in the list control.

    Tog45