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

    HTML
    <div id="button"></div>
    JavaScript
    $(function () {
        $("#button").dxButton({
            text: 'Click me',
            onClick: function() {
                alert("The Button was clicked");
            }
        });
    });
  • Angular

    HTML
    <dx-button
        text="Click me"
        (onClick)="buttonClicked()">
    </dx-button>
    JavaScript
    export class AppComponent {
        buttonClicked() {
            alert("The Button was clicked");
        }
    }
  • AngularJS

    HTML
    <div ng-controller="DemoController">
        <div dx-button="{
            text: 'Click me',
            onClick: buttonClicked
        }"></div>
    </div>
    JavaScript
    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 Wrappers

    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.

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