aspnet-devexpress-dot-web-dot-aspxgridviewcontextmenusettings.md
Gets or sets whether the context menu is enabled.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
[DefaultValue(false)]
public bool Enabled { get; set; }
<DefaultValue(False)>
Public Property Enabled As Boolean
| Type | Default | Description |
|---|---|---|
| Boolean | false |
true, to enable the grid context menu; otherwise, false.
|
You can access this nested property as listed below:
| Library | Object Type | Path to Enabled |
|---|---|---|
| ASP.NET MVC Extensions | GridViewSettings |
.SettingsContextMenu .Enabled
| | MVCxGridViewProperties |
.SettingsContextMenu .Enabled
| | ASP.NET Web Forms Controls | ASPxGridView |
.SettingsContextMenu .Enabled
| | GridViewProperties |
.SettingsContextMenu .Enabled
|
The ASPxGridView provides different context menu types for the following elements: row, column, footer, group footer, and group panel. You can specify the visibility of all context menu types using the Enabled property. To control the menu visibility for a particular element, use the following properties.
The code sample below demonstrates how to provide the default grid context menu with two custom items. To add the items to the item collection, the ContextMenuInitialize event is used. On the client-side, the ASPxClientGridView.ContextMenuItemClick event is handled to respond to a custom item click.
The image below demonstrates a context menu with the custom items.
<dx:ASPxGridView ID="MyGridView" runat="server" AutoGenerateColumns="False" DataSourceID="AccessDataSource" ClientInstanceName="myGrid" KeyFieldName="ProductID" OnContextMenuInitialize="MyGridView_ContextMenuInitialize">
<ClientSideEvents ContextMenuItemClick="function(s, e) {
switch(e.item.name) {
case 'SelectAll':
myGrid.SelectRows();
break;
case 'DeselectAll':
myGrid.UnselectRows();
break;
}
}" />
<Columns>
...
</Columns>
<SettingsBehavior AllowSelectByRowClick="True" />
<SettingsContextMenu Enabled="True">
</SettingsContextMenu>
</dx:ASPxGridView>
protected void MyGridView_ContextMenuInitialize(object sender, ASPxGridViewContextMenuInitializeEventArgs e) {
e.ContextMenu.Items.Add("Select All", "SelectAll");
e.ContextMenu.Items.Add("Deselect All", "DeselectAll");
}
Protected Sub MyGridView_ContextMenuInitialize(ByVal sender As Object, ByVal e As ASPxGridViewContextMenuInitializeEventArgs)
e.ContextMenu.Items.Add("Select All", "SelectAll")
e.ContextMenu.Items.Add("Deselect All", "DeselectAll")
End Sub
See Also
Online Demo: Grid - Context Menu
ASPxGridViewContextMenuSettings Class