diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/prevent-column-menu/columnmenu.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/prevent-column-menu/columnmenu.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/prevent-column-menu/columnmenu.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/prevent-column-menu/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/prevent-column-menu/razor new file mode 100644 index 0000000000..de687463a5 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/prevent-column-menu/razor @@ -0,0 +1,7 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).ShowColumnMenu(true).AllowSorting().AllowFiltering(true).AllowGrouping().Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").ShowColumnMenu(false).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("120").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("130").Add(); +}).FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.CheckBox); }).GroupSettings(group => { group.ShowGroupedColumn(true); }).AllowPaging().Render() diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/prevent-column-menu/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/prevent-column-menu/tagHelper new file mode 100644 index 0000000000..056ef6cbac --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/prevent-column-menu/tagHelper @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-menu.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-menu.md index 5449665d61..ea22f21490 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-menu.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-menu.md @@ -40,6 +40,25 @@ The default column menu items are displayed in following table. > You can customize the default items by defining the [ColumnMenuItems](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) with required items. +## Prevent column menu for particular column + +The Syncfusion® ASP.NET MVC Grid provides the ability to prevent the appearance of the column menu for specific columns. This feature is useful when you want to restrict certain columns from being customizable through the column menu. + +To prevent the column menu for a particular column, you can set the [ShowColumnMenu](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ShowColumnMenu) property to **false** for that specific column configuration. This will disable the column menu options specifically for the designated column, while other columns will have the column menu enabled. + +The following example demonstrates how to prevent the column menu for a specific column. In this example, the column menu is disabled for the **OrderID** column by setting the `ShowColumnMenu` property to **false**. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/prevent-column-menu/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Columnmenu.cs" %} +{% include code-snippet/grid/columns/prevent-column-menu/columnmenu.cs %} +{% endhighlight %} +{% endtabs %} + +![Prevent column menu](../images/column-menu/prevent-column-menu.png) + ## Add custom column menu item The custom column menu item feature allows you to add additional menu items to the column menu in the Syncfusion® Grid. These custom menu items can be defined using the [ColumnMenuItems](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) property, which accepts a collection of `columnMenuItemModel` objects. You can define the actions for these custom items in the [ColumnMenuClick](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuClick) event. diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-menu.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-menu.md index dcd5fbb4ef..266b3cb82d 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-menu.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-menu.md @@ -42,6 +42,25 @@ The default column menu items are displayed in following table. > You can customize the default items by defining the [columnMenuItems](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) with required items. +## Prevent column menu for particular column + +The Syncfusion® ASP.NET Core Grid provides the ability to prevent the appearance of the column menu for specific columns. This feature is useful when you want to restrict certain columns from being customizable through the column menu. + +To prevent the column menu for a particular column, you can set the [showColumnMenu](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ShowColumnMenu) property to **false** for that specific column configuration. This will disable the column menu options specifically for the designated column, while other columns will have the column menu enabled. + +The following example demonstrates how to prevent the column menu for a specific column. In this example, the column menu is disabled for the **OrderID** column by setting the `showColumnMenu` property to **false**. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/prevent-column-menu/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Columnmenu.cs" %} +{% include code-snippet/grid/columns/prevent-column-menu/columnmenu.cs %} +{% endhighlight %} +{% endtabs %} + +![Prevent column menu](../images/column-menu/prevent-column-menu.png) + ## Add custom column menu item The custom column menu item feature allows you to add additional menu items to the column menu in the Syncfusion® Grid. These custom menu items can be defined using the [columnMenuItems](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) property, which accepts a collection of `columnMenuItemModel` objects. You can define the actions for these custom items in the [columnMenuClick](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuClick) event. diff --git a/ej2-asp-core-mvc/grid/images/column-menu/prevent-column-menu.png b/ej2-asp-core-mvc/grid/images/column-menu/prevent-column-menu.png new file mode 100644 index 0000000000..40dabf0485 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-menu/prevent-column-menu.png differ