Class ContextMenuOpenCloseEventArgs
Provides information about the ContextMenuOpening and ContextMenuClosing events.
Inherited Members
Namespace: Syncfusion.Blazor.Spreadsheet
Assembly: Syncfusion.Blazor.Spreadsheet.dll
Syntax
public class ContextMenuOpenCloseEventArgs
Remarks
This arguments object is supplied to subscribers of the ContextMenuOpening and ContextMenuClosing events. It exposes the menu items about to be displayed, the parent item for submenus, the DOM element reference, pointer position coordinates, and a Cancel flag to prevent the open or close action.
The Items collection is dynamic. Subscribers can modify it in place to customize menu behavior (add, remove, hide, disable entries) or assign a new collection to replace all items entirely. Any changes are propagated to the rendered context menu immediately.
The event name in the Name property identifies which lifecycle event is firing, allowing handlers to implement different logic for open vs. close scenarios.
Constructors
ContextMenuOpenCloseEventArgs()
Declaration
public ContextMenuOpenCloseEventArgs()
Properties
Cancel
Gets or sets a value indicating whether the context menu open or close action should be cancelled.
Declaration
public bool Cancel { get; set; }
Property Value
| Type | Description |
|---|---|
| bool | A bool indicating whether to prevent the open or close action. The default value is |
Remarks
Set this property to true to prevent the context menu from opening or closing.
This is useful for implementing custom validation, enforcing user permissions, protecting sensitive areas, or providing conditional menu access based on application state or cell content.
Element
Gets the DOM element reference of the cell or container where the context menu was triggered.
Declaration
public ElementReference Element { get; }
Property Value
| Type | Description |
|---|---|
| ElementReference | An ElementReference representing the HTML element where the right-click or context menu action occurred. The default value is a null reference if the element could not be resolved. |
Remarks
This property provides the Blazor ElementReference to the DOM element that triggered the context menu. You can use this to identify the target cell or determine the context in which the menu is being opened.
The element reference is useful for:
- Identifying the target cell or range
- Reading cell data attributes or properties
- Determining whether the menu should be allowed in that location
- Applying styling or DOM manipulation
Items
Gets or sets the context menu items that are about to be displayed.
Declaration
public List<MenuItem> Items { get; }
Property Value
| Type | Description |
|---|---|
| List<MenuItem> | A List<T> containing the menu items that will be shown in the context menu. The default value is populated with standard context menu items for the triggered location. |
Remarks
This collection is dynamic and allows for runtime customization of the context menu. Subscribers can:
- Hide menu items by setting Hidden to
true - Disable menu items by setting Disabled to
true(grayed out but visible) - Remove items from the collection using standard list operations
- Add custom menu items with application-specific commands
- Assign a new List<T> to completely replace the menu
Changes to the collection are applied to the rendered context menu before it is displayed to the user.
Left
Gets or sets the horizontal (X-axis) position of the context menu in client coordinates.
Declaration
public double? Left { get; set; }
Property Value
| Type | Description |
|---|---|
| double? | A nullable double representing the clientX coordinate (horizontal position) in pixels where the context menu is positioned. The default value is null if the position could not be determined. |
Remarks
This property contains the X-axis coordinate where the user right-clicked or where the context menu was triggered. The coordinate is relative to the viewport (client space), not the document.
This value is useful for:
- Determining the horizontal position where the user triggered the menu
- Implementing context-aware positioning or validation logic
- Detecting whether the menu was triggered on specific columns or areas
- Adjusting menu display based on available screen space
When combined with Top, you can determine the exact screen position of the context menu trigger point.
Name
Gets the name of the event that triggered this arguments object.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string | A string identifying the event type. Possible values include |
Remarks
This property identifies which lifecycle event is currently firing, allowing event handlers to implement different logic for open vs. close scenarios within a single handler method.
Common event names:
"ContextMenuOpening"– Event is firing before the context menu opens"ContextMenuClosing"– Event is firing before the context menu closes
ParentItem
Gets the parent menu item when a submenu context menu is being opened.
Declaration
public MenuItem ParentItem { get; }
Property Value
| Type | Description |
|---|---|
| MenuItem | The parent MenuItem when the context menu represents a submenu; otherwise, null.
The default value is |
Remarks
This property is null when the event is triggered for the top-level context menu.
It contains the parent MenuItem reference when the event represents a submenu popup, allowing you to implement hierarchical menu logic or context-aware behaviors based on the menu hierarchy.
Use this property to determine the menu structure and apply different customizations based on whether the event is for a top-level menu or a submenu.
ScrollHeight
Gets or sets the maximum height of the context menu container when scrolling is enabled.
Declaration
public double ScrollHeight { get; set; }
Property Value
| Type | Description |
|---|---|
| double | A double representing the scrollable menu height in pixels. The default value is |
Remarks
This property specifies the maximum vertical size of the context menu container. When the menu content exceeds this height, scrolling is enabled to show all menu items.
This property is applicable and populated only when:
- The context menu has many items that exceed the viewport height
- Scrolling is enabled in the spreadsheet configuration
- The menu would otherwise extend beyond the visible area
The height is measured in pixels and corresponds to the CSS height applied to the scrollable menu container.
Top
Gets or sets the vertical (Y-axis) position of the context menu in client coordinates.
Declaration
public double? Top { get; set; }
Property Value
| Type | Description |
|---|---|
| double? | A nullable double representing the clientY coordinate (vertical position) in pixels where the context menu is positioned. The default value is null if the position could not be determined. |
Remarks
This property contains the Y-axis coordinate where the user right-clicked or where the context menu was triggered. The coordinate is relative to the viewport (client space), not the document.
This value is useful for:
- Determining the vertical position where the user triggered the menu
- Implementing context-aware positioning logic
- Validating whether the menu should be shown based on location
- Adjusting menu display based on available screen space
When combined with Left, you can determine the exact screen position of the context menu trigger point.