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:
content | The content of the radio button label. Can be a simple string or a string with a custom html. |
---|---|
value | The 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[];
}