Search results

CheckBox

The CheckBox is a graphical user interface element that allows you to select one or more options from the choices. It contains checked, unchecked, and indeterminate states.

<input type="checkbox" id="checkbox"/>
<script>
var checkboxObj = new CheckBox({ label: "Default" });
checkboxObj.appendTo("#checkbox");
</script>

Properties

checked

boolean

Specifies a value that indicates whether the CheckBox is checked or not. When set to true, the CheckBox will be in checked state.

Defaults to false

cssClass

string

Defines class/multiple classes separated by a space in the CheckBox element. You can add custom styles to the CheckBox by using this property.

Defaults to

disabled

boolean

Specifies a value that indicates whether the CheckBox is disabled or not. When set to true, the CheckBox will be in disabled state.

Defaults to false

enableHtmlSanitizer

boolean

Specifies whether to enable the rendering of untrusted HTML values in the CheckBox component. If ‘enableHtmlSanitizer’ set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them.

Defaults to true

enablePersistence

boolean

Enable or disable persisting component’s state between page reloads.

Defaults to false

enableRtl

boolean

Enable or disable rendering component in right to left direction.

Defaults to false

htmlAttributes

{ [key: string]: string }

You can add the additional html attributes such as disabled, value etc., to the element. If you configured both property and equivalent html attribute then the component considers the property value.

Defaults to {}

indeterminate

boolean

Specifies a value that indicates whether the CheckBox is in indeterminate state or not. When set to true, the CheckBox will be in indeterminate state.

Defaults to false

label

string

Defines the caption for the CheckBox, that describes the purpose of the CheckBox.

Defaults to

labelPosition

LabelPosition

Positions label before/after the CheckBox. The possible values are:

  • Before - The label is positioned to left of the CheckBox.
  • After - The label is positioned to right of the CheckBox.

Defaults to ‘After’

locale

string

Overrides the global culture and localization value for this component. Default global culture is ‘en-US’.

Defaults to

name

string

Defines name attribute for the CheckBox. It is used to reference form data (CheckBox value) after a form is submitted.

Defaults to

value

string

Defines value attribute for the CheckBox. It is a form data passed to the server when submitting the form.

Defaults to

Methods

addEventListener

Adds the handler to the given event listener.

Parameter Type Description
eventName string A String that specifies the name of the event
handler Function Specifies the call to run when the event occurs.

Returns void

appendTo

Appends the control within the given HTML element

Parameter Type Description
selector (optional) string | HTMLElement Target element where control needs to be appended

Returns void

attachUnloadEvent

Adding unload event to persist data when enable persistence true

Returns void

click

Click the CheckBox element its native method

Returns void

dataBind

When invoked, applies the pending property changes immediately to the component.

Returns void

destroy

Destroys the widget.

Returns void

detachUnloadEvent

Removing unload event to persist data when enable persistence true

Returns void

focusIn

Sets the focus to CheckBox its native method

Returns void

getLocalData

Returns the persistence data for component

Returns any

getRootElement

Returns the route element of the component

Returns HTMLElement

handleUnload

Handling unload event to persist data when enable persistence true

Returns void

refresh

Applies all the pending property changes and render the component again.

Returns void

removeEventListener

Removes the handler from the given event listener.

Parameter Type Description
eventName string A String that specifies the name of the event to remove
handler Function Specifies the function to remove

Returns void

Inject

Dynamically injects the required modules to the component.

Parameter Type Description
moduleList Function[] ?

Returns void

Events

change

EmitType<ChangeEventArgs>

Triggers when the CheckBox state has been changed by user interaction.

created

EmitType<Event>

Triggers once the component rendering is completed.