Skip to content

Latest commit

 

History

History
884 lines (606 loc) · 16 KB

File metadata and controls

884 lines (606 loc) · 16 KB
layout post
title Properties,Methods and Events of ejCheckBox Widget
description API reference for CheckBox
documentation API
platform angular-api
keywords checkbox, Essential Angular CheckBox, checkbox api

ejCheckBox

The CheckBox control allows you to check an option to perform an action. This control allows you to select true, false or an intermediate option. These CheckBoxes are supported with themes. The HTML CheckBox control is rendered as Essential JavaScript CheckBox control.

Syntax

{% highlight html %}

{% endhighlight %}

Example

{% highlight html %}

{% endhighlight %}

Requires

  • module:jQuery

  • module:ej.core.js

  • module:ej.checkbox.js

Members

checked boolean | string[]

{:#members:checked}

Specifies whether CheckBox has to be in checked or not. We can also specify array of string as value for this property. If any of the value in the specified array matches the value of the textbox, then it will be considered as checked. It will be useful in MVVM binding, specify array type to identify the values of the checked CheckBoxes.

Default Value

  • false

Example

{% highlight html %}

<ej-checkbox id="checkBox" [checked]="true"> Experienced

{% endhighlight %}

checkState enum

{:#members:checkstate}

Specifies the State of CheckBox.See below to get available CheckState

Name Type Default Description
Uncheck string uncheck Enum for Uncheck state checkbox
Check string check Enum for Check state checkbox
Indeterminate string indeterminate Enum for Indeterminate state checkbox

Default Value

  • null

Example

{% highlight html %}

<ej-checkbox id="checkBox" [enableTriState]="true" [checkState]="checkState"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { checkState: string; constructor() { this.checkState = "indeterminate"; } }

{% endhighlight %}

cssClass string

{:#members:cssclass}

Sets the root CSS class for CheckBox theme, which is used customize.

Default Value

  • ""

Example

{% highlight html %}

<ej-checkbox id="checkBox" [cssClass]="customCss"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { customCss: string; constructor() { this.customCss = "gradient-lime"; } }

{% endhighlight %}

enabled boolean

{:#members:enabled}

Specifies the checkbox control state.

Default Value

  • true

Example

{% highlight html %}

<ej-checkbox id="checkBox" [enabled]="true"> Experienced

{% endhighlight %}

enablePersistence boolean

{:#members:enablepersistence}

Specifies the persist property for CheckBox while initialization. The persist API save current model value to browser cookies for state maintains. While refreshing the CheckBox control page the model value apply from browser cookies.

Default Value

  • false

Example

{% highlight html %}

<ej-checkbox id="checkBox" [enablePersistence]="false"> Experienced

{% endhighlight %}

enableRTL boolean

{:#members:enablertl}

Specify the Right to Left direction to Checkbox

Default Value

  • false

Example

{% highlight html %}

<ej-checkbox id="checkBox" [enableRTL]="true"> Experienced

{% endhighlight %}

enableTriState boolean

{:#members:enabletristate}

Specifies the enable or disable Tri-State for checkbox control.

Default Value

  • false

Example

{% highlight html %}

<ej-checkbox id="checkBox" [enableTriState]="true"> Experienced

{% endhighlight %}

htmlAttributes object

{:#members:htmlattributes}

It allows to define the characteristics of the CheckBox control. It will helps to extend the capability of an HTML element.

Default Value

  • {}

Example

{% highlight html %}

<ej-checkbox id="checkBox" [htmlAttributes]="htmlAttributes"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { htmlAttributes: Object; constructor() { this.htmlAttributes = {required:"required"}; } }

{% endhighlight %}

id string

{:#members:id}

Specified value to be added an id attribute of the CheckBox.

Default Value

  • null

Example

{% highlight html %}

<ej-checkbox id="checkBox" [id]="sync"> Experienced

{% endhighlight %}

idPrefix string

{:#members:idprefix}

Specify the prefix value of id to be added before the current id of the CheckBox.

Default Value

  • "ej"

Example

{% highlight html %}

<ej-checkbox id="checkBox" [idPrefix]="idPrefix"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { idPrefix: string; constructor() { this.idPrefix = "ej"; } }

{% endhighlight %}

name string

{:#members:name}

Specifies the name attribute of the CheckBox.

Default Value

  • null

Example

{% highlight html %}

<ej-checkbox id="checkBox" [name]="name"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { name: string; constructor() { this.name = "sync"; } }

{% endhighlight %}

showRoundedCorner boolean

{:#members:showroundedcorner}

Displays rounded corner borders to CheckBox

Default Value

  • false

Example

{% highlight html %}

<ej-checkbox id="checkBox" [showRoundedCorner]="true"> Experienced

{% endhighlight %}

size enum

{:#members:size}

Specifies the size of the CheckBox.See below to know available CheckboxSize

Name Description
Medium Displays the CheckBox in medium size
Small Displays the CheckBox in small size

Default Value

  • "small"

Example

{% highlight html %}

<ej-checkbox id="checkBox" [size]="size"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { size: any; constructor() { this.size = "medium"; } }

{% endhighlight %}

text string

{:#members:text}

Specifies the text content to be displayed for CheckBox.

Default Value

  • ""

Example

{% highlight html %}

<ej-checkbox id="checkBox" [text]="text"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { text: string; constructor() { this.text = "Hello World"; } }

{% endhighlight %}

validationMessage object

{:#members:validationmessage}

Set the jQuery validation error message in CheckBox.

N> The property will work when the widget present inside the form. Additionally need to include jquery.validate.min.js plugin.

Default Value

  • null

Example

{% highlight html %}

<ej-checkbox id="checkBox" [validationRules]="validationRules" [validationMessage]="validationMessage"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { validationRules: Object; validationMessage: Object; constructor() { this.validationRules = {required:true}; this.validationMessage = {required: "Required CheckBox value"}; } }

{% endhighlight %}

validationRules object

{:#members:validationrules}

Set the jQuery validation rules in CheckBox.

N> The property will work when the widget present inside the form. Additionally need to include jquery.validate.min.js plugin.

Default Value

  • null

Example

{% highlight html %}

<ej-checkbox id="checkBox" [validationRules]="validationRules"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { validationRules: Object; constructor() { this.validationRules = {required:true}; } }

{% endhighlight %}

value string

{:#members:value}

Specifies the value attribute of the CheckBox.

Default Value

  • null

Example

{% highlight html %}

<ej-checkbox id="checkBox" [value]="value"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { value: string; constructor() { this.value = "Hello World"; } }

{% endhighlight %}

Methods

destroy()

{:#methods:destroy}

Destroy the CheckBox widget all events bound using this._on will be unbind automatically and bring the control to pre-init state.

Example

{% highlight html %}

Experienced

{% endhighlight %}

{% highlight ts %}

// Create CheckBox instance var checkBoxObj = $("#checkBox").data("ejCheckBox"); checkBoxObj.destroy();// Destroy the CheckBox control

{% endhighlight %}

disable()

{:#methods:disable}

Disable the CheckBox to prevent all user interactions.

Example

{% highlight html %}

Experienced

{% endhighlight %}

{% highlight ts %}

// Create CheckBox instance var checkBoxObj = $("#checkBox").data("ejCheckBox"); checkBoxObj.disable();// disable the CheckBox control

{% endhighlight %}

enable()

{:#methods:enable}

To enable the CheckBox

Example

{% highlight html %}

Experienced

{% endhighlight %}

{% highlight ts %}

// Create CheckBox instance var checkBoxObj = $("#checkBox").data("ejCheckBox"); checkBoxObj.enable();// enables the CheckBox control

{% endhighlight %}

isChecked()

{:#methods:ischecked}

To Check the status of CheckBox

####Returns

boolean

Example

{% highlight html %}

Experienced

{% endhighlight %}

{% highlight ts %}

// Create CheckBox instance var checkBoxObj = $("#checkBox").data("ejCheckBox"); checkBoxObj.isChecked();// check the status of checkbox

{% endhighlight %}

Events

beforeChange

{:#events:beforechange}

Fires before the CheckBox is going to changed its state successfully

Name Type Description
cancel boolean if the event should be canceled; otherwise, false.
model object returns the CheckBox model
type string returns the name of the event
event object returns the event model values
isChecked boolean returns the status whether the element is checked or not.

Example

{% highlight html %}

<ej-checkbox id="checkBox" (beforeChange)="onBeforeChange($event)"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { constructor() { onBeforeChange(e: any){ // Your code here } } }

{% endhighlight %}

ejchange

{:#events:ejchange}

Fires when the CheckBox state is changed successfully

Name Type Description
cancel boolean if the event should be canceled; otherwise, false.
model object returns the CheckBox model
type string returns the name of the event
event object returns the event arguments
isChecked boolean returns the status whether the element is checked or not.
checkState string returns the state of the checkbox

Example

{% highlight html %}

<ej-checkbox id="checkBox" (ejchange)="onChange($event)"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { constructor() { onChange(e: any){ // Your code here } } }

{% endhighlight %}

create

{:#events:create}

Fires when the CheckBox state is created successfully

Name Type Description
cancel boolean if the event should be canceled; otherwise, false.
model object returns the CheckBox model
type string returns the name of the event

Example

{% highlight html %}

<ej-checkbox id="checkBox" (create)="onCreate($event)"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { constructor() { onCreate(e: any){ // Your code here } } }

{% endhighlight %}

destroy

{:#events:destroy}

Fires when the CheckBox state is destroyed successfully

Name Type Description
cancel boolean if the event should be canceled; otherwise, false.
model object returns the CheckBox model
type string returns the name of the event

Example

{% highlight html %}

<ej-checkbox id="checkBox" (destroy)="onDestroy($event)"> Experienced

{% endhighlight %}

{% highlight ts %}

export class AppComponent { constructor() { onDestroy(e: any){ // Your code here } } }

{% endhighlight %}