ASPxGridView.ContextMenuItemVisibility Event
Enables you to dynamically change the visibility and availability of context menu items.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
NuGet Package: DevExpress.Web
#Declaration
public event ASPxGridViewContextMenuItemVisibilityEventHandler ContextMenuItemVisibility
#Event Data
The ContextMenuItemVisibility event's data class is ASPxGridViewContextMenuItemVisibilityEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Items | Gets the collection of items in the context menu. |
Menu |
Gets the currently displayed context menu‘s type. |
The event data class exposes the following methods:
Method | Description |
---|---|
Set |
Allows you to set the availability of a particular item based on the right-clicked column. |
Set |
Allows you to set the availability of a particular item. |
Set |
Allows you to set the availability of a particular item based on the right-clicked row. |
Set |
Allows you to set the visibility of a particular item based on the right-clicked column. |
Set |
Allows you to set the visibility of a particular item. |
Set |
Allows you to set the visibility of a particular item based on the right-clicked row. |
#Remarks
The ContextMenuItemVisibility
event allows you to hide/show and disable/enable context menu items. You can use the event parameter’s properties to access the collection of context menu items (ASPxGridViewContextMenuItemVisibilityEventArgs.Items) and get the displayed menu type (ASPxGridViewContextMenuItemVisibilityEventArgs.MenuType).
Event parameter provides the ASPxGridViewContextMenuItemVisibilityEventArgs.SetVisible and ASPxGridViewContextMenuItemVisibilityEventArgs.SetEnabled methods that allows you to change an item visibility and availability based on the right-clicked row or column.
#MVC Example
settings.ContextMenuItemVisibility = (sender, e) =>
{
if (e.MenuType == GridViewContextMenuType.Rows)
{
MVCxGridView gridView = sender as MVCxGridView;
GridViewContextMenuItem itemExpandAll = e.Items.FindByName("ExpandAll");
GridViewContextMenuItem itemCollapseAll = e.Items.FindByName("CollapseAll");
for (int i = 0; i < gridView.VisibleRowCount; i++)
{
e.SetVisible(itemExpandAll, i, gridView.IsGroupRow(i));
e.SetVisible(itemCollapseAll, i, gridView.IsGroupRow(i));
}
}
};