This is a container that presents a collection of child widgets where each row of the collection is based on a set of original widgets bound with a data source via the ``children`` property.
The set of original widgets define a row of visual elements in the ``WidgetList`` collection. The size of a collection is determined by the number of items in the bound data source, but it may be changed with help of controls displayed by ``aps/WidgetList``. The add and remove row controls may be disabled when creating the widget. Note: all child widgets MUST be bound to a data model (“children: at…” in a ``WidgetList``, “value: at…” in child widgets).
Table of contents
All user panels - CP and UX1
An aps/WidgetList
collection displays a list of widgets rendered from a source data model.
Therefore, it has the following parts:
Data model provides a stateful array of objects that are used to create widgets
Layout specifies which parts of an object and how are presented in each entry of the list
An entry may contain one or more widgets based on various properties of the data model objects.
The size of a collection is initially
determined by the number of items in the bound data source, but a user
can change it by means of the add and remove controls displayed by aps/WidgetList
.
The add and remove row controls may be disabled when creating
the widget.
Find the nested rules for this widget in the recommended Widget Hierarchy.
Module dojox/mvc/at
is required to associate the data source
and the data generated in widgets. For more details
see Model.
The layout of an entry in the list can be based on one of two methods:
Specify all widgets in an entry directly in the aps/WidgetList
definition. In the following example,
an entry will contain two aps/TextBox
input widgets displaying respectively the email
and user
properties a selected object from the model
:
["aps/WidgetList", {
children: at(model, "items")
}, [
["aps/TextBox", { value: at("rel:", "email") }],
["aps/TextBox", { value: at("rel:", "user") }]
]]
Create an HTML template string and specify binding between its nodes and object properties. In the following example, a template declares two input nodes having attach points.
var templateString2 =
"<div class=\"row\">" +
"<input data-dojo-type=\"aps/TextBox\" data-dojo-attach-point=\"firstNode\">" +
"<input data-dojo-type=\"aps/TextBox\" data-dojo-attach-point=\"secondNode\">
</div>";
In the widget definition, you need to specify binding to the attach points, as follows in the example:
["aps/WidgetList", {
children: at(model, "items"),
templateString: templateString2,
childBindings: {
firstNode: { value: at("rel:", "email")},
secondNode: { value: at("rel:", "user")}
}]
If you set showAddRemove
to true, thus enabling the add and remove controls in the list, then
the data model source array referenced by the children
property cannot be empty.
If it is empty during widget creation, an empty object will be automatically added into the array.
An empty object will also be added during creation of each collection
entry. Because of this, you should check the saved objects for emptiness
when getting data from the model.
Direct layout declaration:
require([
"aps/load",
"dojox/mvc/getStateful",
"dojox/mvc/at",
"aps/ready!"
], function(load, getStateful, at){
"use strict";
var model = new getStateful({
"identifier": "id",
"items": [
{ id: "1", email: "max@example.com", user: "Max" },
{ id: "2", email: "tim@example.com", user: "Tim" }
]
});
load(["aps/PageContainer", [
["aps/WidgetList", {
children: at(model, "items")
}, [
["aps/Panel", [
["aps/FieldSet", [
["aps/TextBox", { value: at("rel:", "email") }],
["aps/TextBox", { value: at("rel:", "user") }]
]]]]]]]]);
model.set("items", new getStateful([
{
id: "1",
email: "max345@example.com",
user: "Maxghngh"
},
{
id: "2",
email: "tim345@example.com",
user: "Tighnghnm"
},
{
id: "3",
email: "453423@example.com",
user: "345345345"
}
]));
});
PROPERTY |
TYPE |
DEFAULT |
DESCRIPTION |
---|---|---|---|
dojox/mvc/statefularray |
null |
The array of data model that is used to render child nodes. |
|
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. |
|
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. |
|
number |
-1 |
The upper limit on the number of child widgets. |
|
boolean |
<strong>true</strong> |
If this property is set to false, then the “add” and “remove” row controls are not shown. |
|
boolean |
true |
If this property value is set to true, then the widget is visible. |
The array of data model that is used to render child nodes. Default value: null.
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.
Text that is shown as a label if the widget is placed inside a aps/FieldSet.
Default value: “”.
The upper limit on the number of child widgets. When the number of existing child widgets reaches this limit, the button for adding a widget list is not displayed. Value “-1” means no limit. Default value: -1.
If this property is set to false, then the “add” and “remove” row controls are not shown. The default value of this property is true.
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
|
Destroys this widget |
|
aps/_containerbase
function
|
Focusing the focusable child |
|
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 |
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 |
Destroys 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
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.