React FileManager - contextMenu.items

Configures context menu items' settings.

Selector: Item
Default Value: [ 'create', 'upload', 'rename', 'move', 'copy', 'delete', 'refresh', 'download' ]

The FileManager UI component allows you to add default and custom context menu items.

Predefined Items

Predefined context menu items include:

  • 'create' - Creates a new directory.
  • 'upload' - Uploads a file.
  • 'refresh' - Refreshes the file manager content.
  • 'download' - Downloads a file.
  • 'move' - Moves files and directories.
  • 'copy' - Copies files and directories.
  • 'rename' - Renames files and directories.
  • 'delete' - Deletes files and directories.

To add a predefined item to the context menu, add its name and optional settings ('visible', 'beginGroup', 'text', 'icon', 'disabled') to the items array.

DevExtreme FileManager - Predefined Context Menu Items

App.js
  • import React from 'react';
  • import FileManager, { ContextMenu, Item } from 'devextreme-react/file-manager';
  •  
  • const App = () => {
  • return (
  • <FileManager...>
  • <ContextMenu>
  • <Item name="rename" />
  • <Item name="download" text="Download a File" />
  • <Item name="refresh" beginGroup="true" />
  • </ContextMenu>
  • </FileManager>
  • );
  • };
  •  
  • export default App;

Custom Items

To add a custom context menu item, specify its text and optional settings (for example, a file extension for a newly created file). Use the contextMenuItemClick event to handle clicks on custom context menu items.

DevExtreme FileManager - Custom Context Menu Items

App.js
  • import React from 'react';
  • import FileManager, { ContextMenu, Item } from 'devextreme-react/file-manager';
  •  
  • const App = () => {
  • const onItemClick = (e) => {
  • if(e.itemData.extension) {
  • // your code
  • }
  • };
  •  
  • return (
  • <FileManager onContextMenuItemClick={onItemClick}>
  • <ContextMenu>
  • <Item text="Create .txt Document" extension=".txt" />
  • <Item text="Create .rtf Document" extension=".rtf" />
  • <Item text="Create .xls Document" extension=".xls" />
  • </ContextMenu>
  • </FileManager>
  • );
  • };
  •  
  • export default App;

beginGroup

Specifies whether a group separator is displayed over the item.

Type:

Boolean

You can add group separators only between items in submenus.

closeMenuOnClick

Specifies if a menu is closed when a user clicks the item. Does not apply to the root items.

Type:

Boolean

Default Value: true

disabled

Specifies whether the menu item responds to user interaction.

Type:

Boolean

Default Value: false

icon

Specifies the menu item's icon.

Type:

String

This property accepts one of the following:

items

Configures settings of a context menu item's subitems.

Selector: Item

The FileManager UI component allows you to add default and create custom context menu subitems.

NOTE
You can specify the items option for custom context menu items only.
App.js
  • import React from 'react';
  • import FileManager, { ContextMenu, Item } from 'devextreme-react/file-manager';
  •  
  • const App = () => {
  • return (
  • <FileManager>
  • <ContextMenu>
  • <Item name="create"/>
  • <Item text="Create new file">
  • <Item text="Text Document" extension=".txt" />
  • </Item>
  • </ContextMenu>
  • </FileManager>
  • );
  • };
  •  
  • export default App;

name

Specifies the context menu item's name.

selectable

Specifies whether or not a user can select a menu item.

Type:

Boolean

Default Value: false

selected

Specifies whether or not the item is selected.

Type:

Boolean

Default Value: false

text

Specifies the text inserted into the item element.

Type:

String

If you use both this property and a template, the template overrides the text.

visible

Specifies the context menu item's visibility.

Type:

Boolean

| undefined
Default Value: undefined