Button

The Button widget is a simple button that performs specified commands when a user clicks it.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/button
Export: default
Button interactive configuration
Copy Code
Copy to Codepen
$("#button").dxButton({
});

You can create the widget using one of the following approaches.

jQuery
JavaScript
HTML
$(function () {
    $("#button").dxButton({
        text: 'Click me',
        onClick: function() {
            alert("The Button was clicked");
        }
    });
});
<div id="button"></div>
Angular
HTML
JavaScript
<dx-button
    text="Click me"
    (onClick)="buttonClicked()">
</dx-button>
export class AppComponent {
    buttonClicked() {
        alert("The Button was clicked");
    }
}
AngularJS
HTML
JavaScript
<div ng-controller="DemoController">
    <div dx-button="{
        text: 'Click me',
        onClick: buttonClicked
    }"></div>
</div>
angular.module('DemoApp', ['dx'])
    .controller("DemoController", function ($scope) {
        $scope.buttonClicked = function () {
            alert("The Button was clicked");
        };
    });
Knockout
HTML
<div data-bind="dxButton: {
    text: 'Click me',
    onClick: function () {
        alert('The Button was clicked');
    }
}"></div>
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().Button()
    .ID("button")
    .Text("Click me")
    .OnClick(@<text>
        function () {
            alert("The Button was clicked");
        }
    </text>)
)
@(Html.DevExtreme().Button() _
    .ID("button") _
    .Text("Click me") _
    .OnClick("button_click")
)
<script>
    function button_click() {
        alert("The Button was clicked");
    }
</script>

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the topics in the Installation section.

View Demo

See Also
Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the Button widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.

See Also

Default Template

This section lists the fields of a context object available in a button template.

By default, a predefined template is applied to display the widget. This template is based on the fields of the template context object. Below is the list of these fields. If the default item template is not appropriate for your task, implement a custom template based on these fields or fields of the view model.

See Also