class sap.ui.commons.CheckBox

Control sample: sap.ui.commons.CheckBox
Visiblity: public
UX Guidelines:
Implements: sap.ui.core.IFormContent
Available since: N/A
Module: sap/ui/commons/CheckBox
Application Component: CA-UI5-CTR

Provides a box which can be flagged, the box has a label. A check box can either stand alone, or in a group with other check boxes. As an option, the boxes can initially be set to status 'Not Editable'.


Constructor

Constructor for a new CheckBox.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject#constructor for a general description of the syntax of the settings object.

new sap.ui.commons.CheckBox(sId?, mSettings?)
Param Type Default Value Description
sId? string

id for the new control, generated automatically if no id is given

mSettings? object

initial settings for the new control


Properties

Name Type Default Value Description
checked boolean false

Contains the state of the control whether it is flagged with a check mark, or not

Visibility: public
editable boolean true

Specifies whether the user shall be allowed to select the check box.

Visibility: public
enabled boolean true

Using this property, the control could be disabled, if required.

Visibility: public
name string

The 'name' property to be used in the HTML code, for example for HTML forms that send data to the server via submit.

Visibility: public
text string

Defines the text displayed next to the check box

Visibility: public
textDirection sap.ui.core.TextDirection Inherit

The value can be set to LTR or RTL. Otherwise, the control inherits the text direction from its parent control.

Visibility: public
valueState sap.ui.core.ValueState None

Accepts the core enumeration ValueState.type that supports 'None', 'Error', 'Warning' and 'Success'.

Visibility: public
width sap.ui.core.CSSSize

The width can be set to an absolute value. If no value is set, the control width results from the text length.

Visibility: public

Associations

Name Cardinality Type Description
ariaDescribedBy 0..n sap.ui.core.Control

Association to controls / ids which describe this control (see WAI-ARIA attribute aria-describedby).

ariaLabelledBy 0..n sap.ui.core.Control

Association to controls / ids which label this control (see WAI-ARIA attribute aria-labelledby).


Events Overview

Event Description
change

Event is triggered when the control status is changed by the user by flagging or unflagging the checkbox.

change

Event is triggered when the control status is changed by the user by flagging or unflagging the checkbox.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
checked boolean

Checks whether the box is flagged or not flagged.


Methods Overview

Method Description
addAriaDescribedBy

Adds some ariaDescribedBy into the association ariaDescribedBy.

addAriaLabelledBy

Adds some ariaLabelledBy into the association ariaLabelledBy.

attachChange

Attaches event handler fnFunction to the change event of this sap.ui.commons.CheckBox.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.commons.CheckBox itself.

Event is triggered when the control status is changed by the user by flagging or unflagging the checkbox.

bindChecked

Binds property checked to model data.

See ManagedObject.bindProperty for a detailed description of the possible properties of oBindingInfo

detachChange

Detaches event handler fnFunction from the change event of this sap.ui.commons.CheckBox.

The passed function and listener object must match the ones used for event registration.

sap.ui.commons.CheckBox.extend

Creates a new subclass of class sap.ui.commons.CheckBox with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.Control.extend.

fireChange

Fires event change to attached listeners.

getAccessibilityInfo

References:

  • sap.ui.core.Control#getAccessibilityInfo

getAriaDescribedBy

Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.

getAriaLabelledBy

Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.

getChecked

Gets current value of property checked.

Contains the state of the control whether it is flagged with a check mark, or not

Default value is false.

getEditable

Gets current value of property editable.

Specifies whether the user shall be allowed to select the check box.

Default value is true.

getEnabled

Gets current value of property enabled.

Using this property, the control could be disabled, if required.

Default value is true.

sap.ui.commons.CheckBox.getMetadata

Returns a metadata object for class sap.ui.commons.CheckBox.

getName

Gets current value of property name.

The 'name' property to be used in the HTML code, for example for HTML forms that send data to the server via submit.

getText

Gets current value of property text.

Defines the text displayed next to the check box

getTextDirection

Gets current value of property textDirection.

The value can be set to LTR or RTL. Otherwise, the control inherits the text direction from its parent control.

Default value is Inherit.

getValueState

Gets current value of property valueState.

Accepts the core enumeration ValueState.type that supports 'None', 'Error', 'Warning' and 'Success'.

Default value is None.

getWidth

Gets current value of property width.

The width can be set to an absolute value. If no value is set, the control width results from the text length.

removeAllAriaDescribedBy

Removes all the controls in the association named ariaDescribedBy.

removeAllAriaLabelledBy

Removes all the controls in the association named ariaLabelledBy.

removeAriaDescribedBy

Removes an ariaDescribedBy from the association named ariaDescribedBy.

removeAriaLabelledBy

Removes an ariaLabelledBy from the association named ariaLabelledBy.

setChecked

Sets a new value for property checked.

Contains the state of the control whether it is flagged with a check mark, or not

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

setEditable

Sets a new value for property editable.

Specifies whether the user shall be allowed to select the check box.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

setEnabled

Sets a new value for property enabled.

Using this property, the control could be disabled, if required.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

setName

Sets a new value for property name.

The 'name' property to be used in the HTML code, for example for HTML forms that send data to the server via submit.

When called with a value of null or undefined, the default value of the property will be restored.

setText

Sets a new value for property text.

Defines the text displayed next to the check box

When called with a value of null or undefined, the default value of the property will be restored.

setTextDirection

Sets a new value for property textDirection.

The value can be set to LTR or RTL. Otherwise, the control inherits the text direction from its parent control.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Inherit.

setValueState

Sets a new value for property valueState.

Accepts the core enumeration ValueState.type that supports 'None', 'Error', 'Warning' and 'Success'.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is None.

setWidth

Sets a new value for property width.

The width can be set to an absolute value. If no value is set, the control width results from the text length.

When called with a value of null or undefined, the default value of the property will be restored.

toggle

Inverts the current value of the control.

unbindChecked

Unbinds property checked from model data.

addAriaDescribedBy

Adds some ariaDescribedBy into the association ariaDescribedBy.

Param Type DefaultValue Description
vAriaDescribedBy sap.ui.core.ID sap.ui.core.Control

The ariaDescribedBy to add; if empty, nothing is inserted

addAriaLabelledBy

Adds some ariaLabelledBy into the association ariaLabelledBy.

Param Type DefaultValue Description
vAriaLabelledBy sap.ui.core.ID sap.ui.core.Control

The ariaLabelledBy to add; if empty, nothing is inserted

attachChange

Attaches event handler fnFunction to the change event of this sap.ui.commons.CheckBox.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.commons.CheckBox itself.

Event is triggered when the control status is changed by the user by flagging or unflagging the checkbox.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.ui.commons.CheckBox itself

bindChecked

Binds property checked to model data.

See ManagedObject.bindProperty for a detailed description of the possible properties of oBindingInfo

Param Type DefaultValue Description
oBindingInfo sap.ui.base.ManagedObject.PropertyBindingInfo

The binding information

detachChange

Detaches event handler fnFunction from the change event of this sap.ui.commons.CheckBox.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

sap.ui.commons.CheckBox.extend

Creates a new subclass of class sap.ui.commons.CheckBox with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.Control.extend.

Param Type DefaultValue Description
sClassName string

Name of the class being created

oClassInfo object

Object literal with information about the class

FNMetaImpl function

Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class

fireChange

Fires event change to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

checked boolean

Checks whether the box is flagged or not flagged.

getAccessibilityInfo

References:

getAriaDescribedBy

Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.

getAriaLabelledBy

Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.

getChecked

Gets current value of property checked.

Contains the state of the control whether it is flagged with a check mark, or not

Default value is false.

getEditable

Gets current value of property editable.

Specifies whether the user shall be allowed to select the check box.

Default value is true.

getEnabled

Gets current value of property enabled.

Using this property, the control could be disabled, if required.

Default value is true.

sap.ui.commons.CheckBox.getMetadata

Returns a metadata object for class sap.ui.commons.CheckBox.

getName

Gets current value of property name.

The 'name' property to be used in the HTML code, for example for HTML forms that send data to the server via submit.

getText

Gets current value of property text.

Defines the text displayed next to the check box

getTextDirection

Gets current value of property textDirection.

The value can be set to LTR or RTL. Otherwise, the control inherits the text direction from its parent control.

Default value is Inherit.

getValueState

Gets current value of property valueState.

Accepts the core enumeration ValueState.type that supports 'None', 'Error', 'Warning' and 'Success'.

Default value is None.

getWidth

Gets current value of property width.

The width can be set to an absolute value. If no value is set, the control width results from the text length.

removeAllAriaDescribedBy

Removes all the controls in the association named ariaDescribedBy.

removeAllAriaLabelledBy

Removes all the controls in the association named ariaLabelledBy.

removeAriaDescribedBy

Removes an ariaDescribedBy from the association named ariaDescribedBy.

Param Type DefaultValue Description
vAriaDescribedBy int sap.ui.core.ID sap.ui.core.Control

The ariaDescribedBy to be removed or its index or ID

removeAriaLabelledBy

Removes an ariaLabelledBy from the association named ariaLabelledBy.

Param Type DefaultValue Description
vAriaLabelledBy int sap.ui.core.ID sap.ui.core.Control

The ariaLabelledBy to be removed or its index or ID

setChecked

Sets a new value for property checked.

Contains the state of the control whether it is flagged with a check mark, or not

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

Param Type DefaultValue Description
bChecked boolean false

New value for property checked

setEditable

Sets a new value for property editable.

Specifies whether the user shall be allowed to select the check box.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

Param Type DefaultValue Description
bEditable boolean true

New value for property editable

setEnabled

Sets a new value for property enabled.

Using this property, the control could be disabled, if required.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

Param Type DefaultValue Description
bEnabled boolean true

New value for property enabled

setName

Sets a new value for property name.

The 'name' property to be used in the HTML code, for example for HTML forms that send data to the server via submit.

When called with a value of null or undefined, the default value of the property will be restored.

Param Type DefaultValue Description
sName string

New value for property name

setText

Sets a new value for property text.

Defines the text displayed next to the check box

When called with a value of null or undefined, the default value of the property will be restored.

Param Type DefaultValue Description
sText string

New value for property text

setTextDirection

Sets a new value for property textDirection.

The value can be set to LTR or RTL. Otherwise, the control inherits the text direction from its parent control.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Inherit.

Param Type DefaultValue Description
sTextDirection sap.ui.core.TextDirection Inherit

New value for property textDirection

setValueState

Sets a new value for property valueState.

Accepts the core enumeration ValueState.type that supports 'None', 'Error', 'Warning' and 'Success'.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is None.

Param Type DefaultValue Description
sValueState sap.ui.core.ValueState None

New value for property valueState

setWidth

Sets a new value for property width.

The width can be set to an absolute value. If no value is set, the control width results from the text length.

When called with a value of null or undefined, the default value of the property will be restored.

Param Type DefaultValue Description
sWidth sap.ui.core.CSSSize

New value for property width

toggle

Inverts the current value of the control.

unbindChecked

Unbinds property checked from model data.