Skip to main content

toolitems.factory

ToolitemsFactory : d2/sdk/controls/toolbar/toolitems.factory

Create a new toolbar definiftion. The definition could be used to create a menubar in UI.

Extends: Object
Example (Static toolbar configuration)

define([
'd2/sdk/controls/toolbar/toolitem.factory'
], function(ToolitemsFactory){
'use strict';

return {
rightToolbar: new ToolitemsFactory({
main: [
{
signature: 'D2-RefreshList',
name: 'Refresh',
iconName: 'csui_action_refresh32',
enabled: true
}
]
}, {
maxItemsShown: 1
dropDownText: 'More',
dropDownIconName: 'csui_action_more32'
});
};
});

ToolitemsFactory~ToolitemsFactory

Kind: inner class of ToolitemsFactory

new ToolitemsFactory(toolItems, options)

ParamTypeDescription
toolItemsobject

Key-value pairs where key represents a group name and value represents menu items under that group. Each value should be an array of ToolitemType

optionsobject

Controls options

options.maxItemsShownnumber

Number of menus to be shown at max if this toolbar config is used to draw a menubar. Setting it to 0 shows the menu as dropdown

options.dropDownTextstring

Text shown for dropdown button

options.dropDownIconNamestring

Action icon name for the dropdown button.

ToolitemsFactory~ToolitemType : Object

Kind: inner typedef of ToolitemsFactory
Propety: Boolean [enabled=false] - Whether this menu should be always enabled.
Properties

NameTypeDefaultDescription
signaturestring

Signature of the command bound to this menu item.

namestring

Text displayed for this menu item.

iconNamestring

Action icon name for this menu

commandData*

Arbitrary data. Must have a menuId attribute for uniqueness and equality check.

[subItemOf]string

ID of the menu item for which the current item is a sub-menu

[actionProperties]*

Additional menu configuration data later used by matching command implementations.

[promoted]Booleanfalse

Whether this menu is promoted. Promoted menus represent priority actions that are fetched and shown before others.

typestring

Menu type. Should correlate with action types from D2-REST actions API.

[dynamic]Booleanfalse

Whether this menu is a dynamic menu.