Skip to main content

RadioGroup

RadioGroup is a UI widget for displaying radio groups.

Learn more about the RadioGroup plugin.

constructor​

constructor(opt?: RadioGroup.Options);

The ui.RadioGroup constructor accepts an Options object that encapsulates multiple parameters:

options​

[optional] An array of options. Each option is an object with the following properties:

contentThe content of the radio button label. Can be a simple string or a string with a custom html.
valueThe value of the option. It can be a string, a number or any other JavaScript object.

name​

[optional] Name of the inner input element. By default it is set to the component's cid.

Methods​

render()​

radioGroup.render(): this;

Render the radio group. Note that once you render the color palette, you can use the el property that points to the container HTML element and append it anywhere in the DOM (e.g. document.body.appendChild(radioGroup.el)).

selectByValue(value)​

radioGroup.selectByValue(value: any): void;

Select an item in the radio group by its value.

select(index)​

radioGroup.select(index: number): void;

Select an item in the radio group by its index in the options array.

getCurrentValue()​

radioGroup.getCurrentValue(): any;

Returns the current value of the radio group.

getSelectionIndex()​

radioGroup.getSelectionIndex(): number;

Returns the index value of the current value.

setOptions()​

radioGroup.setOptions(options: RadioGroup.RadioGroupOption[]): void;

Sets new set of options to be rendered inside the radio group component.

remove()​

radioGroup.remove(): this;

Remove the radio group from the DOM.

on()​

radioGroup.on(eventName: string, callback: EventHandler, context?: any): this;

Register a callback function that will be called whenever eventName is triggered. The optional context is an object that will be the context of the handler function (the this).

Events​

option:select​

Triggered when the value of the radio group is selected. The handler passed the current value of the radio group as the first parameter. The second parameter is the RadioGroup object.

Types​

RadioGroupOption​

interface RadioGroupOption {
content: string,
value: any
}

Options​

interface Options extends mvc.ViewOptions<undefined> {
name?: string;
options?: RadioGroupOption[];
}