aspnetcore-js-devexpress-dot-richedit-60a1a44d.md
A context menu item.
export class ContextMenuItem
Initializes a new instance of the ContextMenuItem class with specified settings.
constructor(
id: CommandId | string,
options: IContextMenuItemOptions
)
| Name | Type | Description |
|---|---|---|
| id | string | CommandId |
The item identifier.
| | options | IContextMenuItemOptions |
An object that implements the IContextMenuItemOptions interface and contains context menu item settings.
|
richEdit.contextMenu.insertItem(new DevExpress.RichEdit.ContextMenuItem
(DevExpress.RichEdit.MailMergeTabCommandId.CreateDateField,
{icon: 'clock', text: 'Insert Date Field', beginGroup: true}), 0);
Run Demo: Context Menu Customization
Specifies whether an item separator should be displayed before the current item.
beginGroup: boolean
| Type | Description |
|---|---|
| boolean |
true , to display a separator before the item; otherwise, false.
|
richEdit.contextMenu.insertItem(new DevExpress.RichEdit.ContextMenuItem
(DevExpress.RichEdit.MailMergeTabCommandId.CreateDateField,
{icon: 'clock', text: 'Insert Date Field', beginGroup: true}), 0);
Result:
Specifies whether the context menu item is disabled.
disabled: boolean
| Type | Description |
|---|---|
| boolean |
true , to disable the item; otherwise, false.”
|
function onInit(s) {
s.contextMenu.insertItem(new DevExpress.RichEdit.ContextMenuItem
(DevExpress.RichEdit.HomeTabCommandId.DecreaseFontSize, {
icon: 'minus', text: 'Decrease Font Size',
}), 0);
}
function onContextMenuShowing(s, e) {
var characterProperties = s.selection.activeSubDocument.getCharacterProperties(s.selection.intervals[0]);
if (characterProperties.size < 10) {
e.contextMenu.getItem(DevExpress.RichEdit.HomeTabCommandId.DecreaseFontSize).disabled = true;
}
};
The disable property is not in effect for default context menu items because their availability is determined by the control automatically.
Specifies the item icon’s identifier.
icon?: string
| Type | Description |
|---|---|
| string |
An icon identifier.
|
richEdit.contextMenu.insertItem(new DevExpress.RichEdit.ContextMenuItem
(DevExpress.RichEdit.MailMergeTabCommandId.CreateDateField,
{icon: 'clock', text: 'Insert Date Field', beginGroup: true}), 0);
Specifies the context menu item identifier.
id: CommandId | string
| Type | Description |
|---|---|
| string |
A custom command identifier.
| | CommandId |
The command identifier.
|
var googleSearchId = 'googleSearchId';
function onInit(s) {
s.contextMenu.insertItem(new DevExpress.RichEdit.ContextMenuItem(googleSearchId, {
icon: 'search', beginGroup: true,
}), 0);
s.contextMenu.insertItem(new DevExpress.RichEdit.ContextMenuItem(DevExpress.RichEdit.MailMergeTabCommandId.CreateDateField, {
icon: 'clock', text: 'Insert Date Field'
}), 1);
...
}
function onCustomCommandExecuted(s, e) {
switch (e.commandName) {
case googleSearchId:
var selectedText = s.selection.activeSubDocument.getText(s.selection.intervals[0]);
window.open("https://www.google.com/search?q=" + selectedText, "_blank");
break;
}
}
Provides access to an array of the item’s sub-items.
items?: ContextMenuItem[]
| Type | Description |
|---|---|
| ContextMenuItem[] |
An array of sub-items.
|
var item1 = new DevExpress.RichEdit.ContextMenuItem(DevExpress.RichEdit.HomeTabCommandId.IncreaseFontSize,
{icon: 'plus', text: 'Increase' });
var item2 = new DevExpress.RichEdit.ContextMenuItem(DevExpress.RichEdit.HomeTabCommandId.DecreaseFontSize,
{ icon: 'minus', text: 'Decrease' });
richEdit.contextMenu.insertItem(new DevExpress.RichEdit.ContextMenuItem('item',
{icon: 'chevronnext', text: 'Font Size', items: [item1, item2],}), 0);
Specifies an identifier that allows you to localize the item’s text.
localizationId?: string
| Type | Description |
|---|---|
| string |
The item’s localization identifier.
|
If the text property is specified, the item is not localized.
See Also
Angular Application - Custom Localization Strings
Specifies the item text.
text: string
| Type | Description |
|---|---|
| string |
The item text.
|
richEdit.contextMenu.insertItem(new DevExpress.RichEdit.ContextMenuItem
(DevExpress.RichEdit.MailMergeTabCommandId.CreateDateField,
{icon: 'clock', text: 'Insert Date Field', beginGroup: true}), 0);
Specifies whether the item is visible in the context menu.
visible: boolean
| Type | Description |
|---|---|
| boolean |
true , to display the item; otherwise, false.
|
function onInit(s) {
s.contextMenu.insertItem(new DevExpress.RichEdit.ContextMenuItem
(DevExpress.RichEdit.HomeTabCommandId.DecreaseFontSize, {
icon: 'minus', text: 'Decrease Font Size',
}), 0);
}
function onContextMenuShowing(s, e) {
var characterProperties = s.selection.activeSubDocument.getCharacterProperties(s.selection.intervals[0]);
if (characterProperties.size < 10) {
e.contextMenu.getItem(DevExpress.RichEdit.HomeTabCommandId.DecreaseFontSize).visible = false;
}
};
The visible property is not in effect for default context menu items because their availability is determined by the control automatically.