Toolbar

The dxToolbar is a widget containing items that usually manage screen content. Those items can be plain text or widgets.

Included in: dx.phonejs.js, dx.webappjs.js, dx.all.js
Toolbar interactive configuration
Copy Code
Copy to Codepen
$("#toolbar").dxToolbar({
});

The main option you should specify when creating a widget is the dataSource. The following code snippet demonstrates an example of an array that can be passed to the dataSource option of the dxToolbar widget.

JavaScript
var toolbarItems = [{
    location: 'before',
    widget: 'button',
    options: {
        type: 'back',
        text: 'Back',
        onClick: function (e) {
            DevExpress.ui.notify("Back button clicked", "success", 5000);
        }
    }
}, {
    location: 'menu',
    text: "Add",
    onClick: function () {
        // Process item click
    }
}, {
    location: 'menu',
    text: "Change",
    onClick: function () {
        // Process item click
    }
}, {
    location: 'menu',
    text: "Remove",
    onClick: function () {
        // Process item click
    }
}, {
    location: 'center',
    text: 'Products'
}];

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

  • jQuery
    Use the dxToolbar jQuery plug-in.

    HTML
    <div id="myToolbar"></div>
    JavaScript
    $("#myToolbar").dxToolbar({
        dataSource: toolbarItems
    });
  • Knockout
    Add a div element and apply dxToolbar binding to this element.

    HTML
    <div data-bind="dxToolbar: {
        dataSource: toolbarDataSource
    }"></div>
    JavaScript
    var viewModel = {
        toolbarDataSource: toolbarItems
    }
    ko.applyBindings(viewModel);
  • AngularJS
    Add a div element and apply the dx-toolbar directive to this element.

    HTML
    <div dx-toolbar="{
        dataSource: toolbarDataSource
    }"></div>
    JavaScript
    var myApp = angular.module('myApp', ['dx']);
    myApp.controller("demoController", function ($scope) {
        $scope.toolbarDataSource = toolbarItems;
    });

Note that DevExtreme widgets require you to link the jQuery and Globalize libraries 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 Installation article.

Since the dxToolbar widget is used to display multiple items, it supports common Collection Container widget functionality. You can find detailed information on the principles of working with the widget in the dxToolbar section of the Collection Container Widgets article.

Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the dxToolbar widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.

Default Item Template

This section lists the data source fields that are used in a default template for toolbar items.

By default, a predefined item template is applied to display the items of this widget. This template is based on certain fields of the data source provided for this widget. Below is a list of these fields. If the default item template is not appropriate for your task, implement a custom item template based on these or other fields of your data source.

See Also