Skip to main content
All docs
V24.2

ASPxClientGanttContextMenuItem Class

A context menu item.

Declaration

declare class ASPxClientGanttContextMenuItem

Remarks

The ASPxGantt allows you to customize the built-in (ContextMenuCustomization) or create a custom context menu (ContextMenu).

Run Demo: ASPxGantt - Context Menu Run Demo: MVCxGantt - Context Menu

The built-in context menu supports predefined and custom items. Use the CustomCommand event to handle clicks on custom items. You can call the Clear method to remove predefined items from the context menu.

Web Forms:

<dx:ASPxGantt ID="Gantt" ClientInstanceName="clientGantt" >
    //...
    <ClientSideEvents
      ContextMenuCustomization="function(s, e) {
          // Removes default context menu items
          e.menuItems.Clear();

          // Creates a custom context menu item
          var customItem = new ASPxClientGanttContextMenuItem();
          customItem.name = 'ToggleResourcesVisibility';
          customItem.text = 'Toggle Resources Visibility';
          customItem.beginGroup = true;

          // Adds a custom context menu item
          e.menuItems.Add(customItem);
      }
      CustomCommand="function(s, e) {
          if(e.commandName == 'ToggleResourcesVisibility') {
              showResources = !showResources;
              clientGantt.ShowResources(showResources);
          }
      }
    />
</dx:ASPxGantt>

MVC:

@Html.DevExpress().Gantt(settings => {
    settings.Name = "gantt";
    settings.ClientSideEvents.ContextMenuCustomization = "function (s, e) { 
        // Removes default context menu items
        e.menuItems.Clear();

        // Creates a custom context menu item
        var customItem = new ASPxClientGanttContextMenuItem();
        customItem.name = 'ToggleResourcesVisibility';
        customItem.text = 'Toggle Resources Visibility';
        customItem.beginGroup = true;

        // Adds a custom context menu item
        e.menuItems.Add(customItem);
    }";
    settings.ClientSideEvents.CustomCommand = "function (s, e) { 
        if(e.commandName == 'ToggleResourcesVisibility') {
            showResources = !showResources;
            clientGantt.ShowResources(showResources);
        }
    }";
    ...
}).Bind(
    GanttDataProvider.Tasks, GanttDataProvider.Dependencies, 
    GanttDataProvider.Resources, GanttDataProvider.ResourceAssignments
).GetHtml()

Examples

See Also