v7.3.0

Container
Widget

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);

If you are looking for a more powerful container that can have toolbars, a title bar, and more see Panel.

No results

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 true to make a focus of a focusable encapsulating element relay focus down into a focusable child. This is normally false to allow mousedown to begin text selection in Popups.

  • gridColumns : Number
    internal

    Number of columns to use in a grid layout. Applied as grid-template-columns: repeat(n, auto). Also applies the b-columns CSS class to the container.

    Has a corresponding runtime gridColumns property.

  • isolateFields : Booleanfalse
    internal

    Specify true to 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 true to 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 true to match fields by their name property only when assigning a record, without falling back to ref.

    Has a corresponding runtime strictRecordMapping property.

Properties

Properties are getters/setters or publicly accessible variables on this class
  • firstItem : Widget
    READONLY

    Returns the first widget in this Container.

  • gridColumns : Number
    internal

    Number of columns to use in a grid layout. Applied as grid-template-columns: repeat(n, auto). Also applies the b-columns CSS class to the container.

    Has a corresponding gridColumns config.

  • initialItems : Boolean
    internal
    READONLY

    This property is true until the container's initial items config has been processed. This property is set to false by the updateItems method.

  • Returns true if currently setting values. Allow fields to change highlighting to distinguishing between initially setting values and later on changing values.

  • isValid : Boolean
    READONLY

    Returns true if all contained fields are valid, otherwise false

  • lastItem : Widget
    READONLY

    Returns the last widget in this Container.

  • isContainer : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of Container class, or subclass thereof.
  • Specify true to match fields by their name property only when assigning a record, without falling back to ref.

    Has a corresponding strictRecordMapping config.

  • The number of visible child items shown in this Container.

  • widgetMap : Object<String, Widget>
    READONLY

    An object which contains a map of descendant widgets keyed by their ref. All descendant widgets will be available in the widgetMap.

Functions

Functions are methods available for calling on the class

    Events

    Events are triggered for certain actions in this class and can be listened for to react to those actions in your code

    Event handlers

    Event handlers are callbacks called as a result of certain actions in this class

    CSS variables

    CSS variables that can be set to adjust appearance
    Name Description
    --b-container-align-content Containers align-content setting
    --b-container-border-color Border color for bordered containers
    --b-container-border-width Border width for bordered containers
    --b-container-color Containers color setting
    --b-container-gap Gap between container items
    --b-container-padding Container padding
    --b-divider-font-size Divider font size
    --b-divider-font-weight Divider font weight
    --b-divider-line-color Divider line color
    --b-divider-margin-block Divider block margin
    --b-divider-text-color Divider text color
    type: container

    Source path

    Core/widget/Container.js

    Contents