dashboard-js-devexpress-dot-dashboard-caad79d1.md
A toolbar item.
export interface ViewerToolbarItem
The Web Dashboard allows you to customize the dashboard item caption and dashboard title. For instance, you can add custom command buttons, create additional popup menus, add static texts, etc. Use the DashboardItemCaptionToolbarOptions and DashboardTitleToolbarOptions classes to create a toolbar item of the specified type (like custom buttons or static text). The ViewerToolbarItem object represents a toolbar item.
Use the ViewerApiExtensionOptions.onItemCaptionToolbarUpdated and ViewerApiExtensionOptions.onDashboardTitleToolbarUpdated handlers to customize the dashboard item’s caption and dashboard title.
You can use predefined colors for toolbar icons to make the icons consistent with the entire dashboard application. For example, you can use the predefined color for a new item caption button. In this case, the button’s color depends on the selected Web Dashboard theme.
The table below lists the available predefined color classes:
| Class Name | Description |
|---|---|
| dx-dashboard-icon | The theme’s primary color. |
| dx-dashboard-contrast-icon | The theme’s additional color. |
| dx-dashboard-accent-icon | The theme’s accent color. |
| dx-dashboard-green-icon | A green hue based on the theme. |
| dx-dashboard-red-icon | A red hue based on the theme. |
| dx-dashboard-yellow-icon | A yellow hue based on the theme. |
Add the class="Class Name" attribute to the icon’s svg definition to specify the icon’s color.
<div style="display: none;">
<svg id="green-circle" class="dx-dashboard-green-icon" viewBox="0 0 24 24" width="48" height="48"><circle cx="12" cy="12" r="11" /></svg>
<svg id="yellow-circle" class="dx-dashboard-yellow-icon" viewBox="0 0 24 24" width="48" height="48"><circle cx="12" cy="12" r="11" /></svg>
<svg id="red-circle" class="dx-dashboard-red-icon" viewBox="0 0 24 24" width="48" height="48"><circle cx="12" cy="12" r="11" /></svg>
</div>
For the dx-dashboard-icon class, you can change an icon’s color when it is hovered (like the Maximize or Export to buttons). To do this, add the style="fill: currentColor" attribute to the svg definition:
<div style="display: none;">
<svg id="base-triangle" class="dx-dashboard-icon" style="fill: currentColor" viewBox="0 0 24 24" width="24" height="24"><path d="M12 3 L3 21 L21 21 Z" /></svg>
<svg id="base-circle" class="dx-dashboard-icon" style="fill: currentColor" viewBox="0 0 24 24" width="24" height="24"><circle cx="12" cy="12" r="11" /></svg>
</div>
The following example shows how to add a toolbar item to the dashboard item caption: add a new toolbar item, customize the existing toolbar item, and delete a specific element from the toolbar items collection.
The customizeCaptionToolbar function below do the following:
itemClick method call returns the item’s component name.itemClick method call returns a name of the clicked item.The image below shows the added toolbar items:
Handle the ViewerApiExtensionOptions.onItemCaptionToolbarUpdated event depending on your platform and call the custom customizeCaptionToolbar function in the event handler:
function customizeCaptionToolbar(e) {
// Add a new toolbar item to the caption for each dashboard item.
e.options.actionItems.push({
type: "button",
icon: "base-triangle",
hint: "Show Component Name",
click: function () {
DevExpress.ui.notify("The component name of this dashboard item is " + e.itemName, "info");
}
});
// Add a new toolbar item to the caption for the specific Chart item.
if (e.itemName === "chartDashboardItem1") {
e.options.actionItems.push({
type: "menu",
icon: "base-circle",
menu: {
type: "icons",
items: ["green-circle", "yellow-circle", "red-circle"],
selectionMode: "none",
title: "Circles",
itemClick: function (itemData) {
DevExpress.ui.notify("This is " + itemData.toString(), "success");
}
}
});
}
// Change the existing toolbar item in the caption.
if (e.itemName === "listBoxDashboardItem1") {
var caption = e.options.staticItems.filter(function (item) {
return item.name === 'item-caption'
});
if (caption.length > 0) {
caption[0].text = 'Filter';
}
}
// Remove the existing toolbar item from the caption.
if (e.itemName === "chartDashboardItem1") {
e.options.staticItems = e.options.staticItems.filter(function (item) {
return item.name !== 'item-caption'
});
}
}
<div style="display: none;">
<svg id="base-circle" class="dx-dashboard-icon" style="fill: currentColor" viewBox="0 0 24 24" width="24" height="24"><circle cx="12" cy="12" r="11" /></svg>
<svg id="green-circle" class="dx-dashboard-green-icon" viewBox="0 0 24 24" width="48" height="48"><circle cx="12" cy="12" r="11" /></svg>
<svg id="yellow-circle" class="dx-dashboard-yellow-icon" viewBox="0 0 24 24" width="48" height="48"><circle cx="12" cy="12" r="11" /></svg>
<svg id="red-circle" class="dx-dashboard-red-icon" viewBox="0 0 24 24" width="48" height="48"><circle cx="12" cy="12" r="11" /></svg>
</div>
Specifies a value indicating whether the toolbar item is enabled.
checked?: boolean
| Type | Description |
|---|---|
| boolean |
true , if the toolbar item is enabled; otherwise, false.
|
Specifies a custom function that is executed when a button click occurs.
click?: (element: DevExpress.Dashboard.DxElement) => void
| Type | Description |
|---|---|
| (element: DxElement) => void |
A function that is executed when a button click occurs.
|
The click event is raised for the toolbar item when its ViewerToolbarItem.type is button. For the menu value, use the ViewerToolbarItemMenu.itemClick property to raise the click event for a specific popup menu item.
Specifies whether the current toolbar item is disabled and cannot be clicked.
disabled?: boolean
| Type | Description |
|---|---|
| boolean |
true , to disable a toolbar item; otherwise, false.
|
Specifies the text displayed as a toolbar item’s hint.
hint?: string
| Type | Description |
|---|---|
| string |
A string value that is a toolbar item’s hint.
|
The hint property displays a simple popup hint with additional information about the item being hovered over. To provide a complex tooltip, use the tooltip property.
Specifies the id from the icon’s SVG definition.
icon?: string
| Type | Description |
|---|---|
| string |
A string that is the id from the icon’s SVG definition.
|
Web Dashboard supports icons in the SVG format. To provide an icon for the toolbar item, add the SVG definition onto the page and assign the id value from the definition to the icon property.
See Predefined Colors for information on which color constants you can use to natively embed an icon in the Web Dashboard application.
The recommended icon size is 24 x 24 px.
Note
The dashboard toolbar item is not displayed in the caption / title if neither the text nor icon properties are set.
Specifies a toolbar item’s menu.
menu?: ViewerToolbarItemMenu
| Type | Description |
|---|---|
| ViewerToolbarItemMenu |
A ViewerToolbarItemMenu object that is a toolbar item’s menu.
|
Specifies a toolbar item’s unique name.
name?: string
| Type | Description |
|---|---|
| string |
A string value that is a toolbar item’s unique name.
|
Go to dashboardToolbarItemNames to get a list of predefined names.
Specifies a custom template for a toolbar item in the dashboard item caption and dashboard title.
template?: () => JQuery | Element | string
| Type | Description |
|---|---|
| () => string | Element |
An object that defines a template or specifies its name.
|
Specifies a text you can display in the toolbar item.
text?: string
| Type | Description |
|---|---|
| string |
A string value that is a toolbar item’s title.
|
Note
The text property is not in effect if you set the icon property.
Note
The dashboard toolbar item is not displayed in the caption / title if neither the text nor icon properties are set.
Specifies the text displayed as a toolbar item’s tooltip.
tooltip?: ViewerToolbarItemTooltip | string
| Type | Description |
|---|---|
| string |
A string value that is a toolbar item’s tooltip.
| | ViewerToolbarItemTooltip |
A ViewerToolbarItemTooltip object that is a tooltip.
|
The tooltip property displays a customized popup hint with additional information about the item being hovered over. You can create a specified template to display a complex tooltip.
To provide a simple hint, use the hint property.
Specifies the type of the dashboard toolbar item.
type?: "button" | "menu" | "text"
| Name | Description |
|---|---|
| "button" |
Defines a clickable button.
| | "menu" |
Defines a pop-up menu.
| | "text" |
Defines an additional text you can display in the caption / title.
|
The following properties are not in effect for the text dashboard toolbar item: