Skip to main content

Radio Group


A "Radio Group" displays a set of predefined options (radio buttons) that a user can select.

Radio Buttons

A radio button is a circular button that can either be selected or deselected. Upon selecting one button, the others in the group automatically deselect.

Radio groups are used in applications where users need to select a single option from a list. They can improve the user experience by making it clear which option has been selected and by preventing users from selecting more than one option.

Adding Data to the Radio Group

There are three methods for adding "Data" to the radio group, they are as follows:

  • Direct - Manually entering the data
  • Static - Hardcoding the data
  • Dynamic - Using API to source external-data

Direct Method

To add custom data directly to the radio list.

Step 01 Click on the data icon.

RadioGroup

*It's the 2nd from left on the bottom-right of the screen

Step 02 Enter the desired display name in the "label" field and the corresponding bind name in the "value" field.

RadioGroup

Step 03 Click the "Add" button.

onPreload

The "onPreLoad" feature is available under the "Data" tab. [Make sure that the radio group is your currently selected widget]

Step 01. Select the data icon.

Step 02 Click onPreoad to open the "Code Editor" window. (Note: Can't see the "onPreload" button? Ensure you have selected the 'Async' checkbox.)

table

Now, on the Code Editor screen, use the following script to add your custom data.

async function main(asset) {
// const option = { label: '', value: '' }
// const returnValue = [option, option]

// return array of options(s) to populate radiobutton
}

onClick

You can also use the “onClick” feature of other widgets (such as buttons) to populate the radio group. Use the following script on the Code Editor screen of the widget to add your custom data.

async function main(asset) {
// const option = { label: '', value: '' }
// const data = [option, option]

a8forms.RadioButton("radioButtonID").setData(data)
}

Radio Group Properties

PropertyDescription
Direction
(Vertical/Horizontal)
Sets the direction of display for the radio group list.

API Methods

setData

Adds the specified "Data" to the Radio Group.

setData(data: {label: string, value: string}[]): void

setReadOnly

Sets the ReadOnly flag for this component.

setReadOnly(readOnly: boolean): void

setVisibility

Sets the Visibility flag for this component.

setVisibility(visible: boolean): void

setVisibilityCondition

Sets the visibility condition for this component.

setVisibilityCondition(condition: string): void

Event Handlers

Event handlers allow you to set triggers for various actions based on the fired events. They are as follows:

onChange

onChange - Triggers a specified action every time there's a change to the component's "value".