Table Of Contents

aps/RadioButton

Creates an HTML radio-button.

Compatibility

All user panels - CP and UX1

Overview

The RadioButton widget is a modified analog of the radioButton HTML element.

In addition to the standard properties of the HTML element, such as value, checked, and disabled. the widget may have description (description), a name for displaying in a FieldSet (label or title), and may also have child elements. As with a usual HTML element, grouping of several RadioButton widgets is implemented by specifying the same value for their name property. For more information about the name property see Base Properties and Methods.

Note

In the next versions, we will implement a special widget for the aps/RadioButton group. If you already use the aps/RadioButton group, you can monitor user activity by means of the onClick method.

var val;
load(["aps/FieldSet", [
   ["aps/Panel", [
      ["aps/RadioButton", {
         name: 'test',
         onClick: function(){ val = 1; }
      }],
      ["aps/RadioButton", {
         name: 'test',
         onClick: function(){ val = 2; }
      }],
      ["aps/RadioButton", {
         name: 'test',
         onClick: function(){ val = 3; }
      }]
]]]]);

Find the nested rules for this widget in the recommended Widget Hierarchy.

The widget may also have child widgets from the input category.

Examples

The Declarations section describes generally the methods of widget declaration.

Declaration using Loader

RUN DEMO

require(["aps/load", "aps/ready!"],
  function(load){
    "use strict";

    load(["aps/PageContainer", [
        ["aps/Panel", [
            ["aps/RadioButton", {
                value: "loader",
                description: "I am RadioButton"
            }]
    ]]]]);
});

Declaration using Constructor

RUN DEMO

require(["aps/RadioButton", "aps/Panel", "aps/PageContainer", "aps/ready!"],
  function(RadioButton, Panel, PageContainer){
    "use strict";

    var page = new PageContainer({}, "simpleRadioButton");
    var panel = new Panel();
    panel.addChild(new RadioButton({
      value: "program",
      description: "I am RadioButton"
    }));
    page.addChild(panel);
    page.startup();
});

Radio Button as a Parent

RUN DEMO

require(['dijit/registry', 'aps/load', 'aps/ready!'],
    function(registry, load) {
        load(["aps/Panel", [
            ["aps/FieldSet", {
                    title: "Input parameters"
                },
                [
                    ["aps/RadioButton", {
                        name: "inputs",
                        id: "btn1",
                        gridSize: "md-12 xs-12",
                        //hint: "Available",
                        description: "Save all predefined parameters",
                        onClick: function() {
                            registry.byId('predefined').set('visible', false);
                            registry.byId('inputbox').set('visible', false);
                        }
                    }],
                    ["aps/RadioButton", {
                            name: "inputs",
                            id: "btn2",
                            gridSize: "md-12 xs-12",
                            description: "Select predefined parameters",
                            onClick: function() {
                                registry.byId('predefined').set('visible', true);
                                registry.byId('inputbox').set('visible', false);
                            }
                        },
                        [
                            ["aps/FieldSet", {
                                    id: "predefined",
                                    visible: false
                                },
                                [
                                    ["aps/CheckBox", {
                                        id: "cb1",
                                        gridSize: "md-6 xs-12",
                                        description: "param1='start'"
                                    }],
                                    ["aps/CheckBox", {
                                        id: "cb2",
                                        gridSize: "md-6 xs-12",
                                        description: "param2='stop'"
                                    }]
                                ]
                            ]
                        ]
                    ],
                    ["aps/RadioButton", {
                            name: "inputs",
                            id: "btn3",
                            gridSize: "md-12 xs-12",
                            description: "Enter custom parameters",
                            onClick: function() {
                                registry.byId('predefined').set('visible', false);
                                registry.byId('inputbox').set('visible', true);
                            }
                        },
                        [
                            ["aps/FieldSet", [
                                ["aps/TextBox", {
                                    id: "inputbox",
                                    gridSize: "md-12 xs-12",
                                    visible: false,
                                    autoSize: false,
                                    placeHolder: "param1='value1' param2='value2'"
                                }]

                            ]]
                        ]
                    ]
                ]
            ]
        ]]);
});

Public Properties

PROPERTY

TYPE

DEFAULT

DESCRIPTION

autoSize

boolean

true

Only for PCP / CCP v1.

checked

boolean

false

If the widget is checked, then true.

description

string

“”

Textual description to be displayed as a small greyed text under the control.

disabled

boolean

false

Specifies if the widget will respond to user input.

gridSize

string

undefined

This specifies the widget width that is relevant only for widgets inside Container, FieldSet, or Tiles.

hint

string

“”

Help information in a widget.

isBusy

boolean

false

If the widget is busy then this property is true.

label

string

“”

Text that is shown as a label if the widget is placed inside a aps/FieldSet.

name

string

“”

A string specifying the relationship between several widgets.

optionalText

string

undefined

Text for optional widgets of the Input category.

placeHolder

string

“”

Grayed out initial string in a field.

required

boolean

false

User is required to enter data in the input field.

size

number

10 - PCP / CCP v1, undefined - CCP v2

Affects the selection of a CSS class that defines the width of the input field of the widget.

value

string

“”

Current value of the widget.

visible

boolean

true

If this property value is set to true, then the widget is visible.

autoSize boolean

Only for PCP / CCP v1. If this property value is set to “true”, then a CSS class is assigned to the widget based on the value of the “size” property: size <= 7 - f-small-size (40px) 7 < size <= 33 - f-middle-size (215px) 33 < size - f-big-size (240px) The default value of this property is true. If you want to use your own CSS class for defining the widget’s size, you should set this property value to “false” and specify your class name in the widget’s “class” property. Default value: true

checked boolean

If the widget is checked, then true. Default value: false.

description string

Textual description to be displayed as a small greyed text under the control. Default value: “”.

disabled boolean

Specifies if the widget will respond to user input.

Default value: false.

gridSize string

This specifies the widget width that is relevant only for widgets inside Container, FieldSet, or Tiles. In other cases it will be ignored.

gridSize string contains few options with number values (from 1 to 12) separated by spaces, which specify the grid size of the widget in different layouts:

- md - desktop

- xs - phone

For example, gridSize: “md-4 xs-2”.

All values below 1, e.g. “md-0”, will be replaced with the empty string (“”), values above 12, e.g. “md-14”, will be reduced to 12 (“md-12”).

Default value: undefined.

hint string

Help information in a widget. It is shown under the content of the widget. Deprecated in CCP v2. Default value: “”.

isBusy boolean

If the widget is busy then this property is true.

Default value: false.

label string

Text that is shown as a label if the widget is placed inside a aps/FieldSet.

Default value: “”.

name string

A string specifying the relationship between several widgets. Default value: “”.

optionalText string

Text for optional widgets of the Input category. Default value: undefined.

placeHolder string

Grayed out initial string in a field. For example, it can display instructions. Default value: “”.

required boolean

User is required to enter data in the input field. Default value: false.

size number

Affects the selection of a CSS class that defines the width of the input field of the widget.

size <= 7        f-small-size (40px)
7 < size <= 33   f-middle-size (215px)
size > 33        f-big-size (240px)

Default value: 10 - PCP / CCP v1, undefined - CCP v2.

value string

Current value of the widget. Default value: “”.

visible boolean

If this property value is set to true, then the widget is visible.

Default value: true.

Public Methods

METHOD

RETURN

DESCRIPTION

addChild (child, insertIndex)

undefined

Makes the given widget a child of this widget

cancel ()

object

Sets the isBusy property to false

destroy ()

undefined

Destroy this widget

focus ()

aps/_input
function

Focusing on the focusNode of the current object

get ()

any

Get a property of the Stateful instance

getChildren ()

array

Returns all direct children of this widget, i

getParents ()

array

Discover and return all parents of the widget

placeAt ()

dijit/_widgetbase
function

Place this widget somewhere in the DOM based on standard dojo/dom-construct::place() conventions

removeAll ()

undefined

Remove all children in the widget

removeChild (widget)

undefined

Removes the passed widget instance from this widget and destroys it

reset ()

undefined

Resets the widget

set ()

object
function

Set a property of the Stateful instance

startup ()

undefined

Gets started after the DOM fragment is added to the document

validate ()

boolean

Called by oninit, onblur, and onkeypress

addChild

Makes the given widget a child of this widget. Inserts specified child widget’s dom node as a child of this widget’s container node, and possibly does other processing (such as layout).

Return: undefined

ARGUMENT

TYPE

DESCRIPTION

child

Widget

Child widget

insertIndex

Number
String

Position child in the parent widget

cancel

Sets the isBusy property to false.

Return: object

destroy

Destroy this widget. Will also destroy any resources (including widgets) registered via this.own(). This method will also destroy internal widgets such as those created from a template.

Return: undefined

focus

Focusing on the focusNode of the current object.

Return: aps/_input function

get

Get a property of the Stateful instance. Get a named property of the Stateful object. The property may potentially be retrieved via a getter method in subclasses.

In the base class, this just retrieves the object’s property.

Return: any

getChildren

Returns all direct children of this widget, i.e. all widgets underneath this.containerNode whose parent is this widget. Note that it returns not all descendetns, but only the direct children. Analogous to Node.childNodes, except containing widgets rather than DOMNodes.

The result intentionally excludes internally created widgets (a.k.a. supporting widgets) outside of this.containerNode.

Note the returned array is a simple array. The application code should not assume existence of methods like forEach().

Return: array

getParents

Discover and return all parents of the widget.

Return: array

placeAt

Place this widget somewhere in the DOM based on standard dojo/dom-construct::place() conventions. A convenience function providing a simple shorthand mechanism to put an existing (or newly created) widget somewhere in the DOM, and allow chaining.

Return: dijit/_widgetbase function

removeAll

Remove all children in the widget.

Return: undefined

removeChild

Removes the passed widget instance from this widget and destroys it. You can also pass in an integer indicating the index within the container to remove (ie, removeChild(5) removes the sixth widget).

Return: undefined

ARGUMENT

TYPE

DESCRIPTION

widget

Widget
Int

Child widget or index

reset

Resets the widget.

Return: undefined

set

Set a property of the Stateful instance. Sets named properties of the stateful object and notifies the watchers of the property. A programmatic setter may be defined in subclasses.

Return: object function

startup

Gets started after the DOM fragment is added to the document Called after the widget and its children have been created and added to the page, and all related widgets have finished their create() cycle, up through postCreate().

Note that startup() may be called while the widget is still hidden, for example if the widget is inside a hidden dijit/Dialog or an unselected tab of a dijit/layout/TabContainer. For widgets that need to do layout, it’s best to put that layout code inside resize(), and then extend dijit/layout/_LayoutWidget so that resize() is called when the widget is visible.

Return: undefined

validate

Called by oninit, onblur, and onkeypress. Show missing or invalid messages if appropriate, and highlight textbox field.

Return: boolean

Public Events

EVENT

RETURN

DESCRIPTION

onClick ()

undefined

The method is called when a user clicks on the widget

onClick

The method is called when a user clicks on the widget.