Creates an HTML radio-button.
Table of contents
All user panels - CP and UX1
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.
The Declarations section describes generally the methods of widget declaration.
require(["aps/load", "aps/ready!"],
function(load){
"use strict";
load(["aps/PageContainer", [
["aps/Panel", [
["aps/RadioButton", {
value: "loader",
description: "I am RadioButton"
}]
]]]]);
});
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();
});
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'"
}]
]]
]
]
]
]
]]);
});
PROPERTY |
TYPE |
DEFAULT |
DESCRIPTION |
---|---|---|---|
boolean |
true |
Only for PCP / CCP v1. |
|
boolean |
false |
If the widget is checked, then true. |
|
string |
“” |
Textual description to be displayed as a small greyed text under the control. |
|
boolean |
false |
Specifies if the widget will respond to user input. |
|
string |
undefined |
This specifies the widget width that is relevant only for widgets inside Container, FieldSet, or Tiles. |
|
string |
“” |
Help information in a widget. |
|
boolean |
false |
If the widget is busy then this property is true. |
|
string |
“” |
Text that is shown as a label if the widget is placed inside a aps/FieldSet. |
|
string |
“” |
A string specifying the relationship between several widgets. |
|
string |
undefined |
Text for optional widgets of the Input category. |
|
string |
“” |
Grayed out initial string in a field. |
|
boolean |
false |
User is required to enter data in the input field. |
|
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. |
|
string |
“” |
Current value of the widget. |
|
boolean |
true |
If this property value is set to true, then the widget is visible. |
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
If the widget is checked, then true. Default value: false.
Textual description to be displayed as a small greyed text under the control. Default value: “”.
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.
Help information in a widget. It is shown under the content of the widget. Deprecated in CCP v2. Default value: “”.
Text that is shown as a label if the widget is placed inside a aps/FieldSet.
Default value: “”.
A string specifying the relationship between several widgets. Default value: “”.
Text for optional widgets of the Input category. Default value: undefined.
Grayed out initial string in a field. For example, it can display instructions. Default value: “”.
User is required to enter data in the input field. Default value: false.
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.
Current value of the widget. Default value: “”.
If this property value is set to true, then the widget is visible.
Default value: true.
METHOD |
RETURN |
DESCRIPTION |
---|---|---|
undefined
|
Makes the given widget a child of this widget |
|
object
|
Sets the isBusy property to false |
|
undefined
|
Destroy this widget |
|
aps/_input
function
|
Focusing on the focusNode of the current object |
|
any
|
Get a property of the Stateful instance |
|
array
|
Returns all direct children of this widget, i |
|
array
|
Discover and return all parents of the widget |
|
dijit/_widgetbase
function
|
Place this widget somewhere in the DOM based on standard dojo/dom-construct::place() conventions |
|
undefined
|
Remove all children in the widget |
|
undefined
|
Removes the passed widget instance from this widget and destroys it |
|
undefined
|
Resets the widget |
|
object
function
|
Set a property of the Stateful instance |
|
undefined
|
Gets started after the DOM fragment is added to the document |
|
boolean
|
Called by oninit, onblur, and onkeypress |
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 |
---|---|---|
|
Widget
|
Child widget |
|
Number
String
|
Position child in the parent widget |
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
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
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
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
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
Int
|
Child widget or index |
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
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
Called by oninit, onblur, and onkeypress. Show missing or invalid messages if appropriate, and highlight textbox field.
Return: boolean
EVENT |
RETURN |
DESCRIPTION |
---|---|---|
undefined
|
The method is called when a user clicks on the widget |
The method is called when a user clicks on the widget.