Skip to content
This repository has been archived by the owner. It is now read-only.

Latest commit

 

History

History
857 lines (593 loc) · 16 KB

File metadata and controls

857 lines (593 loc) · 16 KB
layout post
title Properties, Methods and Events of Button Widget
description API reference for Button
documentation API
platform angular-api
keywords Button, Essential Angular Button, button api

ejButton

Custom Design for HTML Button control.

Syntax

{% highlight html %}

{% endhighlight %}

Example

{% highlight html %}

{% endhighlight %}

Requires

  • module:jQuery

  • module:ej.core.js

  • module:ej.button.js

Members

contentType enum

{:#members:contenttype}

Specifies the contentType of the Button. See below to know available ContentType

Name Description
TextOnly To display the text content only in button
ImageOnly To display the image only in button
ImageBoth Supports to display image for both ends of the button
TextAndImage Supports to display image with the text content
ImageTextImage Supports to display image with both ends of the text

Default Value

  • ej.ContentType.TextOnly

Example

{% highlight html %}

<input type="button" ej-button id="button" [contentType]="contentType" [prefixIcon]="prefixIcon" />

{% endhighlight %}

{% highlight ts %}

export class AppComponent { contentType: any; prefixIcon: string; constructor() { this.contentType = ej.ContentType.ImageOnly; this.prefixIcon = "e-icon e-handup"; } }

{% endhighlight %}

cssClass string

{:#members:cssclass}

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

Default Value

  • ""

Example

{% highlight html %}

<input type="button" ej-button id="button" [cssClass]="customCss" />

{% endhighlight %}

{% highlight ts %}

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

{% endhighlight %}

enabled boolean

{:#members:enabled}

Specifies the button control state.

Default Value

  • true

Example

{% highlight html %}

<input type="button" ej-button id="button" [enabled]="false" />

{% endhighlight %}

enableRTL boolean

{:#members:enablertl}

Specify the Right to Left direction to button

Default Value

  • false

Example

{% highlight html %}

<input type="button" ej-button id="button" [enableRTL]="true" />

{% endhighlight %}

height number

{:#members:height}

Specifies the height of the Button.

Default Value

  • 28

Example

{% highlight html %}

<input type="button" ej-button id="button" [height]="height" />

{% endhighlight %}

{% highlight ts %}

export class AppComponent { height: string; constructor() { this.height = "30px"; } }

{% endhighlight %}

htmlAttributes object

{:#members:htmlattributes}

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

Default Value

  • {}

Example

{% highlight html %}

<input type="button" ej-button id="button" [htmlAttributes]="htmlAttributes" />

{% endhighlight %}

{% highlight ts %}

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

{% endhighlight %}

imagePosition enum

{:#members:imageposition}

Specifies the image position of the Button. This image position is applicable only with the textandimage contentType property. The images can be positioned in both imageLeft and imageRight options. See below to know about available ImagePosition

Name Description
ImageRight support for aligning text in left and image in right
ImageLeft support for aligning text in right and image in left
ImageTop support for aligning text in bottom and image in top.
ImageBottom support for aligning text in top and image in bottom

Default Value

  • ej.ImagePosition.ImageLeft

Example

{% highlight html %}

<input type="button" ej-button id="button" [contentType]="contentType" [imagePosition]="imagePosition" [prefixIcon]="prefixIcon" />

{% endhighlight %}

{% highlight ts %}

export class AppComponent { prefixIcon: string; imagePosition: any; contentType: any; constructor() { this.prefixIcon = "e-icon e-handup"; this.imagePosition = ej.ImagePosition.ImageRight; this.contentType = ej.ContentType.TextAndImage; } }

{% endhighlight %}

prefixIcon string

{:#members:prefixicon}

Specifies the primary icon for Button. This icon will be displayed from the left margin of the button.

N> This is applicable for the content type's imageonly, textandimage, imagetextimage and imageboth.

Default Value

  • null

Example

{% highlight html %}

<input type="button" ej-button id="button" [contentType]="contentType" [prefixIcon]="prefixIcon" />

{% endhighlight %}

{% highlight ts %}

export class AppComponent { prefixIcon: string; imagePosition: any; contentType: any; constructor() { this.prefixIcon = "e-icon e-handup"; this.contentType = "imageonly"; } }

{% endhighlight %}

repeatButton boolean

{:#members:repeatbutton}

Convert the button as repeat button. It raises the 'Click' event repeatedly from the it is pressed until it is released.

Default Value

  • false

Example

{% highlight html %}

<input type="button" ej-button id="button" [repeatButton]="true" />

{% endhighlight %}

showRoundedCorner boolean

{:#members:showroundedcorner}

Displays the Button with rounded corners.

Default Value

  • false

Example

{% highlight html %}

<input type="button" ej-button id="button" [showRoundedCorner]="true" />

{% endhighlight %}

size enum

{:#members:size}

Specifies the size of the Button. See below to know available ButtonSize

Name Description
Normal Creates button with Built-in default size height, width specified
Mini Creates button with Built-in mini size height, width specified
Small Creates button with Built-in small size height, width specified
Medium Creates button with Built-in medium size height, width specified
Large Creates button with Built-in large size height, width specified

Default Value

  • ej.ButtonSize.Normal

Example

{% highlight html %}

<input type="button" ej-button id="button" [size]="size" />

{% endhighlight %}

{% highlight ts %}

export class AppComponent { size: any; constructor() { this.size = ej.ButtonSize.Mini; } }

{% endhighlight %}

suffixIcon string

{:#members:suffixicon}

Specifies the secondary icon for Button. This icon will be displayed from the right margin of the button.

N> This is applicable for the content type's imagetextimage and imageboth.

Default Value

  • null

Example

{% highlight html %}

<input type="button" ej-button id="button" [contentType]="contentType" [suffixIcon]="suffixIcon" [prefixIcon]="prefixIcon" [text]="text" />

{% endhighlight %}

{% highlight ts %}

export class AppComponent { contentType: any; suffixIcon: string; prefixIcon: string; text: string; constructor() { this.contentType = "imageboth"; this.suffixIcon = "e-icon e-file-html"; this.prefixIcon = "e-icon e-search"; this.text = "FileSearch"; } }

{% endhighlight %}

text string

{:#members:text}

Specifies the text content for Button.

Default Value

  • null

Example

{% highlight html %}

<input type="button" ej-button id="button" [text]="text" />

{% endhighlight %}

{% highlight ts %}

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

{% endhighlight %}

timeInterval string

{:#members:timeinterval}

Specified the time interval between two consecutive 'click' event on the button.

N> This is applicable for while the button in repeat button mode.

Default Value

  • "150"

Example

{% highlight html %}

<input type="button" ej-button id="button" [repeatButton]="true" [timeInterval]="timeInterval" />

{% endhighlight %}

{% highlight ts %}

export class AppComponent { timeInterval: number; constructor() { this.timeInterval = 100; } }

{% endhighlight %}

type enum

{:#members:type}

Specifies the Type of the Button. See below to know available ButtonType

Name Description
Button Creates button with Built-in button type specified
Reset Creates button with Built-in reset type specified
Submit Creates button with Built-in submit type specified

Default Value

  • ej.ButtonType.Submit

Example

{% highlight html %}

<input type="button" ej-button id="button" [type]="type" />

{% endhighlight %}

{% highlight ts %}

export class AppComponent { type: any; constructor() { this.type = ej.ButtonType.Submit; } }

{% endhighlight %}

width string | number

{:#members:width}

Specifies the width of the Button.

Default Value

  • "100px"

Example

{% highlight html %}

<input type="button" ej-button id="button" [width]="width" />

{% endhighlight %}

{% highlight ts %}

export class AppComponent { width: any; constructor() { this.width = "150px"; } }

{% endhighlight %}

Methods

destroy()

{:#methods:destroy}

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

Example

{% highlight html %}

{% endhighlight %}

{% highlight ts %}

var buttonObj = $("#button1").data("ejButton"); // Create instance of Button buttonObj.destroy(); // destroy the button

{% endhighlight %}

disable()

{:#methods:disable}

To disable the button

Example

{% highlight html %}

{% endhighlight %}

{% highlight ts %}

var buttonObj = $("#button1").data("ejButton"); // Create instance of Button buttonObj.disable(); // disable the button

{% endhighlight %}

enable()

{:#methods:enable}

To enable the button

Example

{% highlight html %}

{% endhighlight %}

{% highlight ts %}

var buttonObj = $("#button1").data("ejButton"); // Create instance of Button buttonObj.enable(); // enable the button

{% endhighlight %}

Events

ejclick

{:#events:ejclick}

Fires when Button control is clicked successfully.Consider the scenario to perform any validation,modification of content or any other operations click on button,we can make use of this click event to achieve the scenario.

Name Type Description
cancel boolean if the event should be canceled; otherwise, false.
model object returns the button model
type string returns the name of the event
status boolean return the button state
e object return the event model for sever side processing.

Example

{% highlight html %}

<input type="button" ej-button id="button1" value="Button" (ejclick)="onClick($event)" />

{% endhighlight %}

{% highlight ts %}

export class AppComponent { constructor(){ } onClick(e: any){ // Write a code block to perform operation while click on button. }

}

{% endhighlight %}

create

{:#events:create}

Fires after Button control is created.If the user want to perform any operation after the button control creation then the user can make use of this create event.

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

Example

{% highlight html %}

<input type="button" ej-button id="button1" value="Button" (create)="onCreate($event)" />

{% endhighlight %}

{% highlight ts %}

export class AppComponent { constructor(){ } onCreate(e: any){ // Write a code block to perform operation after creating the button. }

}

{% endhighlight %}

destroy

{:#events:destroy}

Fires when the button is destroyed successfully.If the user want to perform any operation after the destroy button control then the user can make use of this destroy event.

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

Example

Example

{% highlight html %}

<input type="button" ej-button id="button1" value="Button" (destroy)="onDestroy($event)" />

{% endhighlight %}

{% highlight ts %}

export class AppComponent { constructor(){ } onDestroy(e: any){ // Write a code block to perform operation after destroy the button. }

}

{% endhighlight %}