CheckboxGroup

The CheckboxGroup widget contains a set of related Checkbox widgets.

For example, to present three choices and have the user select one or more of them:

 const checkboxGroup = new CheckboxGroup({
     appendTo : document.body,
     title    : 'Select cities',
     name     : 'cities',
     value    : 'London',  // the default choice
     options  : {
         London    : 'London',
         Madrid    : 'Madrid',
         Stockholm : 'Stockholm',
         Sydney    : 'Sydney'
     }
 });

Checkbox group
//<code-header>
fiddle.title = 'Checkbox group';
//</code-header>
const checkboxGroup = new CheckboxGroup({
    appendTo : targetElement,
    title    : 'Select cities',
    name     : 'cities',
    value    : ['London', 'Sydney'],  // the default selection
    options  : {
        London    : 'London',
        Madrid    : 'Madrid',
        Stockholm : 'Stockholm',
        Sydney    : 'Sydney',
        Miami     : 'Miami'
    },
    onChange() {
        targetElement.lastElementChild.innerText = `Selected: ${this.value.join(', ')}`;
    }
});

const label = document.createElement('span');
targetElement.appendChild(label);
checkboxGroup.onChange();

The name config is required for this widget, and it will be assigned to all checkboxes created by processing the options config.

Vertical or horizontal layout

The default orientation is vertical, but you can change it to horizontal by setting the inline config to true.

Horizontal checkbox group
//<code-header>
fiddle.title = 'Horizontal checkbox group';
//</code-header>
const checkboxGroup = new CheckboxGroup({
    appendTo : targetElement,
    title    : 'Select cities',
    inline   : true, // Horizontal layout
    name     : 'cities',
    value    : 'London',  // the default choice
    options  : {
        London    : 'London',
        Madrid    : 'Madrid',
        Stockholm : 'Stockholm',
        Sydney    : 'Sydney'
    }
});

Disabled

Disabled checkbox group
//<code-header>
fiddle.title = 'Disabled checkbox group';
//</code-header>
const checkboxGroup = new CheckboxGroup({
    appendTo : targetElement,
    title    : 'Select cities',
    name     : 'cities',
    disabled : true,
    value    : 'London',  // the default choice
    options  : {
        London    : 'London',
        Madrid    : 'Madrid',
        Stockholm : 'Stockholm',
        Sydney    : 'Sydney'
    }
});

Validation

You can set requiredSelectedOptions, minSelectedOptions and maxSelectedOptions to force users to select the right amount of options.

Checkbox group validation
//<code-header>
fiddle.title = 'Checkbox group validation';
//</code-header>
const checkboxGroup = new CheckboxGroup({
    appendTo           : targetElement,
    title              : 'Life wishlist (select up to 3)',
    name               : 'cities',
    value              : ['A', 'B', 'C'],  // the default selection
    minSelectedOptions : 1,
    maxSelectedOptions : 3,
    options            : {
        A : 'Fame',
        B : 'Money',
        C : 'Friends',
        D : 'Long life',
        E : 'No typescript errors'
    }
});

Configs

119

Common

listenersEvents

Other

The maximum number of options to select

The minimum number of options to select

options: Object<String, (String|CheckboxConfig)>

The set of options for this checkbox group. The keys of this object hold the checkbox's checkedValue while the object values are a string for the checkbox's text or a config object for that checkbox.

The value of this checkbox group will be one of the keys in this object or null if no checkbox is checked.

Example:

 {
     type    : 'checkboxgroup',
     name    : 'resolution',
     value   : 'A',
     title   : 'Allergies',
     options : {
         A : 'Gluten',
         B : 'Bacon',
         C : 'Lactose',
         D : 'Fish'
     }
 }

The number of options the user is required to select for this field to be valid. See also minSelectedOptions and maxSelectedOptions if you would like to use a range.

This property corresponds to the checkedValue of all the currently checked checkboxes.

Accepts a comma-separated string representing the checked values.

clearableRadioGroup
columnWidget
defaultFocusContainer
drawerPanel
inlineFieldSet
labelPositionContainer
nameRadioGroup
renditionContainer
rtlRTL
spanWidget

Accessibility

ariaLabelWidget
keyMapKeyMap

Content

bbarPanel
defaultsContainer
footerPanel
headerPanel
itemsContainer
lazyItemsContainer
namedItemsContainer
stripsPanel
tbarPanel
textContentContainer
toolsPanel

CSS

bodyClsPanel
borderContainer
clsWidget
colorWidget
htmlClsWidget
itemClsContainer
styleWidget
uiPanel

DOM

adoptWidget
appendToWidget
contentWidget
datasetWidget
htmlWidget
idWidget
tagWidget

Float & align

alignWidget
anchorWidget
centeredWidget
draggableWidget
floatingWidget
xWidget
yWidget

Label

labelLabelable
labelClsLabelable
labelWidthLabelable

Layout

alignSelfWidget
dockWidget
flexWidget
heightWidget
hiddenWidget
hideWhenEmptyContainer
layoutContainer
layoutStyleContainer
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
textAlignWidget
weightWidget
widthWidget

misc

tabBarItemsContainer

Misc

dataFieldWidget
disabledWidget
iconPanel
localeClassLocalizable
localizableLocalizable
maskedWidget
ownerWidget
readOnlyWidget
refWidget
rippleWidget
tabWidget
titlePanel
tooltipWidget

Record

recordContainer

Scrolling

State

stateIdState

Properties

103

Class hierarchy

isCheckboxGroup: Boolean= truereadonly
Identifies an object as an instance of CheckboxGroup class, or subclass thereof.
isCheckboxGroup: Boolean= truereadonlystatic
Identifies an object as an instance of CheckboxGroup class, or subclass thereof.
isContainerContainer
isDelayableDelayable
isEventsEvents
isFieldSetFieldSet
isKeyMapKeyMap
isLabelableLabelable
isLocalizableLocalizable
isPanelPanel
isRadioGroupRadioGroup
isStateState
isToolableToolable
isWidgetWidget

Other

The maximum number of options to select

The minimum number of options to select

The number of options the user is required to select for this field to be valid. See also minSelectedOptions and maxSelectedOptions if you would like to use a range.

This property corresponds to the checkedValue of all the currently checked checkboxes.

Accepts a comma-separated string representing the checked values.

$namestaticWidget
columnWidget
firstItemContainer
hasChangesContainer
inlineFieldSet
isValidContainer
itemsContainer
labelPositionContainer
lastItemContainer
renditionContainer
rtlRTL
spanWidget
toolsPanel
typestaticWidget
valuesContainer

Accessibility

keyMapKeyMap

Content

bbarPanel
tbarPanel

CSS

clsWidget

DOM

appendToWidget
contentWidget
datasetWidget
elementWidget
htmlWidget
idWidget
styleWidget

Float & align

xWidget
yWidget

Layout

alignSelfWidget
flexWidget
heightWidget
layoutContainer
layoutStyleContainer
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
widthWidget

Lifecycle

configBase

Misc

cellInfoWidget
disabledWidget
labelLabelable
localeHelperLocalizable
localeManagerLocalizable
readOnlyWidget
refWidget
tabWidget
titlePanel
tooltipWidget

Record

recordContainer

State

stateState

Visibility

hiddenWidget
isVisibleWidget

Widget hierarchy

ownerWidget
parentWidget
widgetMapContainer

Functions

74

Configuration

applyDefaultsstaticBase

Events

Float & align

alignToWidget
setXYWidget
showByWidget
toFrontWidget

Lifecycle

createstaticWidget
destroystaticBase
initClassstaticWidget

Misc

attachTooltipstaticWidget
fromElementstaticWidget
fromSelectorstaticWidget
getByIdstaticWidget
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

addContainer
composeWidget
createOnFrameDelayable
disableWidget
enableWidget
focusWidget
getAtContainer
getWidgetByIdContainer
insertContainer
LstaticLocalizable
maskWidget
onEvents
recomposeWidget
relayAllEvents
removeContainer
removeAllContainer
resetValuesContainer
setValuesContainer
triggerEvents
unEvents
unmaskWidget

State

Visibility

hideWidget
showWidget

Widget hierarchy

closestWidget
containsWidget
ownsWidget
queryWidget
queryAllWidget
upWidget

Events

23

Fired before one of the checkboxes is toggled, return false to prevent the action.

// Adding a listener using the "on" method
checkboxGroup.on('beforeChange', ({ value, source }) => {

});
ParameterTypeDescription
valueString[]

This widget's value

sourceCheckboxGroup

This widget

Fired when one of the checkboxes is toggled.

// Adding a listener using the "on" method
checkboxGroup.on('change', ({ value, source }) => {

});
ParameterTypeDescription
valueString[]

This widget's value

sourceCheckboxGroup

This widget

catchAllEvents
destroyEvents
expandPanel
focusInWidget
focusOutWidget
hideWidget
paintWidget
readOnlyWidget
recomposeWidget
resizeWidget
showWidget

Event handlers

23

Called before one of the checkboxes is toggled, return false to prevent the action.

new CheckboxGroup({
    onBeforeChange({ value, source }) {

    }
});
ParameterTypeDescription
valueString[]

This widget's value

sourceCheckboxGroup

This widget

Called when one of the checkboxes is toggled.

new CheckboxGroup({
    onChange({ value, source }) {

    }
});
ParameterTypeDescription
valueString[]

This widget's value

sourceCheckboxGroup

This widget

onDestroyEvents
onFocusInWidget
onHideWidget
onPaintWidget
onResizeWidget
onShowWidget

Typedefs

7

CSS variables

59