React Gantt - contextMenu
Selector: ContextMenu
Type:
items[]
Selector: Item
The context menu contains a set of default commands: 'addTask', 'taskDetails', and 'deleteTask'. Use the contextMenu property to recreate the context menu items.
To add a predefined item to the context menu, add its name and optional settings (for example, 'visible', 'text', and 'icon') to the items collection.
App.js
- import React from 'react';
- import Gantt, { ContextMenu } from 'devextreme-react/gantt';
- const App = () => {
- return (
- <Gantt...>
- <ContextMenu>
- <Item name="addTask" />
- <Item name="deleteTask" />
- <Item text="Zoom">
- <Item name="zoomIn" />
- <Item name="zoomOut" />
- </Item>
- </ContextMenu>
- </Gantt>
- );
- };
- export default App;
Custom Items
To add a custom context menu item, specify its text and optional settings (for example, name or category). Use the customCommand event to handle clicks on custom context menu items.
App.js
- import React from 'react';
- import Gantt, { ContextMenu } from 'devextreme-react/gantt';
- const App = () => {
- const onCustomCommand = (e) => {
- if(e.name == 'item1') {
- // your code
- }
- };
- return (
- <Gantt
- onCustomCommand={onCustomCommand} >
- <ContextMenu>
- <Item text="Category">
- <Item name="item1" text="Item 1" />
- <Item name="item2" text="Item 2" />
- <Item name="item3" text="Item 3" />
- </Item>
- </ContextMenu>
- </Gantt>
- );
- }
- export default App;
Result:
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.