Container
A Widget that can contain other widgets. Uses a CSS Grid layout by default, either use CSS or see the layout config to apply another layout.
// Create a container with two widgets
const container = new Container({
items : {
name : { type : 'textfield', label : 'Name' },
score : { type : 'numberfield', label : 'Score' }
}
});
Label position & input field alignment
Fields support placing labels either before or above them. This can be set for all fields in a container at once by specifying the labelPosition config. It supports 3 settings:
'above'- Labels are placed above the field. For text fields in the Material3 theme, this means ~ on the fields top border.'before'- Labels are placed before the field.'align-before'- Labels are placed before the field and the fields are arranged in a two column layout (used in the live demo above).
align-before setting cannot be used in conjunction with specifying a Container layout.When using 'align-before', the container uses display: grid to lay out the fields. You can override this by specifying a different grid-template-columns value in your CSS. To get two equal width columns, use:
.b-container.b-columns {
grid-template-columns: 1fr 1fr;
}
If you want input elements aligned to the right / end side of your container, enable inputFieldAlign as seen in the demo below.
Adding and removing child widgets
Containers can have child widgets added, or removed during their lifecycle to accommodate business needs. For example:
// Insert a child widget before another field
myContainer.insert(textField, someField)
// Remove a child widget
myContainer.remove(checkboxField);
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Update fields if the record changes
-
Can be set to
trueto make a focus of a focusable encapsulating element relay focus down into a focusable child. This is normallyfalseto allow mousedown to begin text selection in Popups. -
Number of columns to use in a grid layout. Applied as
grid-template-columns: repeat(n, auto). Also applies theb-columnsCSS class to the container.Has a corresponding runtime gridColumns property.
-
Specify
trueto isolate record changes to this container and its ancestors. Prevents record updates from propagating up from here and also prevents record updates from parent from propagating down to us. -
Set
trueto add a border to this container's element. -
An optional CSS class to add to child items of this container.
-
A config object containing default settings to apply to all child widgets.
-
Update assigned record automatically on field changes
-
Specify
trueto match fields by theirnameproperty only when assigning a record, without falling back toref.Has a corresponding runtime strictRecordMapping property.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Container class, or subclass thereof.
-
Returns the first widget in this Container.
-
Number of columns to use in a grid layout. Applied as
grid-template-columns: repeat(n, auto). Also applies theb-columnsCSS class to the container.Has a corresponding gridColumns config.
-
This property is
trueuntil the container's initialitemsconfig has been processed. This property is set tofalseby theupdateItemsmethod. -
Returns
trueif currently setting values. Allow fields to change highlighting to distinguishing between initially setting values and later on changing values. -
Returns
trueif all contained fields are valid, otherwisefalse -
Returns the last widget in this Container.
-
Identifies an object as an instance of Container class, or subclass thereof.
-
Specify
trueto match fields by theirnameproperty only when assigning a record, without falling back toref.Has a corresponding strictRecordMapping config.
-
The number of visible child items shown in this Container.
-
An object which contains a map of descendant widgets keyed by their ref. All descendant widgets will be available in the
widgetMap.