UI Widgets Toolbar

A toolbar widget.

Included in: dx.phonejs.js, dx.webappjs.js, dx.all.js

The dxToolbar widget displays a set of widgets usually used to manage screen content.

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

  • jQuery
    Use the dxToolbar jQuery plug-in.

    HTML
    <div id="toolbar"></div>
    JavaScript
    var toolbarItems = [
        {
            location: 'before',
            widget: 'button',
            options: {
                type: 'back',
                text: 'Back',
                onClick: buttonClickHandler
            } 
        },
        {
            location: 'after', widget: 'dropDownMenu', options: {
                items: ["Add", "Change", "Remove"],
                onItemClick: menuItemClickHandler
            }
        },
        { location: 'center', text: 'Products' }
    ];
    $("#toolbar").dxToolbar({
        dataSource: toolbarItems
    });
  • Knockout
    Add a div element and apply the dxToolbar binding to this element.

    HTML
    <div data-bind="dxToolbar: {
        dataSource: toolbarItems
    }"></div>
  • Angular
    Add a div element and apply the dx-toolbar directive to this element.

    HTML
    <div dx-toolbar="{
        dataSource: toolbarItems
    }"></div>

Note that DevExtreme widgets require you to link the jQuery and Globalize libraries to your application. If you use the Knockout or Angular approach, the Knockout or Angular library is also required.

See Also

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
<div ng-controller="demoController">
    <div dx-toolbar="{ dataSource: toolbarItems }"></div>
</div>
var showText = function (e) {
    DevExpress.ui.notify("Back button clicked", "success", 5000);
};
var menuItemClicked = function (e) {
    DevExpress.ui.notify(e.model.text + " item clicked", "success", 2000);
};
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
    $scope.toolbarItems = [
        { location: 'before', widget: 'button', options: { type: 'back', text: 'Back', onClick: showText }},
        { location: 'menu', text: "Add", onClick: menuItemClicked },
        { location: 'menu', text: "Change", onClick: menuItemClicked },
        { location: 'menu', text: "Remove", onClick: menuItemClicked },
        { location: 'center', text: 'Products' }
    ];
});
angular.element(document).ready(function () {
    angular.bootstrap(document, ['myApp']);
});
<div data-bind="dxToolbar: { dataSource: toolbarItems }"></div>
var showText = function(e) {
    DevExpress.ui.notify( "Back button clicked", "success", 5000 );
};
var menuItemClicked = function (e) {
    DevExpress.ui.notify(e.model.text + " item clicked", "success", 2000);
};
var myViewModel = {
    toolbarItems: [
        { location: 'before', widget: 'button', options: { type: 'back', text: 'Back', onClick: showText } },
        { location: 'menu', text: "Add", onClick: menuItemClicked },
        { location: 'menu', text: "Change", onClick: menuItemClicked },
        { location: 'menu', text: "Remove", onClick: menuItemClicked },
        { location: 'center', text: 'Products' }
    ]
}
ko.applyBindings(myViewModel);
<div id="myToolbar"></div>
var showText = function (e) {
    DevExpress.ui.notify("Back button clicked", "success", 5000);
};
var menuItemClicked = function (e) {
    DevExpress.ui.notify(e.model.text + " item clicked", "success", 2000);
};
$("#myToolbar").dxToolbar({
    dataSource: [
        { location: 'before', widget: 'button', options: { type: 'back', text: 'Back', onClick: showText } },
        { location: 'menu', text: "Add", onClick: menuItemClicked },
        { location: 'menu', text: "Change", onClick: menuItemClicked },
        { location: 'menu', text: "Remove", onClick: menuItemClicked },
        { location: 'center', text: 'Products' }
    ]
});

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 exposed 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