Back to Devexpress

ASPxGridViewContextMenuSettings.Enabled Property

aspnet-devexpress-dot-web-dot-aspxgridviewcontextmenusettings.md

latest5.5 KB
Original Source

ASPxGridViewContextMenuSettings.Enabled Property

Gets or sets whether the context menu is enabled.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue(false)]
public bool Enabled { get; set; }
vb
<DefaultValue(False)>
Public Property Enabled As Boolean

Property Value

TypeDefaultDescription
Booleanfalse

true, to enable the grid context menu; otherwise, false.

|

Property Paths

You can access this nested property as listed below:

LibraryObject TypePath to Enabled
ASP.NET MVC ExtensionsGridViewSettings

.SettingsContextMenu .Enabled

| | MVCxGridViewProperties |

.SettingsContextMenu .Enabled

| | ASP.NET Web Forms Controls | ASPxGridView |

.SettingsContextMenu .Enabled

| | GridViewProperties |

.SettingsContextMenu .Enabled

|

Remarks

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.

Example

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.

aspx
<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>
csharp
protected void MyGridView_ContextMenuInitialize(object sender, ASPxGridViewContextMenuInitializeEventArgs e) {
     e.ContextMenu.Items.Add("Select All", "SelectAll");
     e.ContextMenu.Items.Add("Deselect All", "DeselectAll");
}
vb
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

Context Menu

Context Menu

Grid View

Online Demo: Grid - Context Menu

ASPxGridViewContextMenuSettings Class

ASPxGridViewContextMenuSettings Members

DevExpress.Web Namespace