Skip to content

Commit cf0d31a

Browse files
Merge pull request #4106 from syncfusion-content/EJ2-950978-column-menu
950978: Included the prevent column menu topic
2 parents 6c3f0d0 + 100b641 commit cf0d31a

File tree

6 files changed

+61
-0
lines changed

6 files changed

+61
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
public IActionResult Index()
2+
{
3+
var Order = OrdersDetails.GetAllRecords();
4+
ViewBag.DataSource = Order;
5+
return View();
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.DataSource).ShowColumnMenu(true).AllowSorting().AllowFiltering(true).AllowGrouping().Columns(col =>
2+
{
3+
col.Field("OrderID").HeaderText("Order ID").Width("120").ShowColumnMenu(false).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
4+
col.Field("CustomerID").HeaderText("Customer ID").Width("120").Add();
5+
col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
6+
col.Field("ShipCity").HeaderText("Ship City").Width("130").Add();
7+
}).FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.CheckBox); }).GroupSettings(group => { group.ShowGroupedColumn(true); }).AllowPaging().Render()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<ejs-grid id="Grid" dataSource="@ViewBag.DataSource" allowPaging='true' allowGrouping='true' allowSorting='true' showColumnMenu='true' allowFiltering='true' >
2+
<e-grid-groupsettings showGroupedColumn="true"></e-grid-groupsettings>
3+
<e-grid-filtersettings type="CheckBox"></e-grid-filtersettings>
4+
<e-grid-columns>
5+
<e-grid-column field='OrderID' headerText='Order ID' showColumnMenu='false' textAlign='Right' width="120"></e-grid-column>
6+
<e-grid-column field="CustomerID" headerText="Customer ID" width="120"></e-grid-column>
7+
<e-grid-column field="Freight" headerText="Freight" format='C' textAlign="Right" width="130"></e-grid-column>
8+
<e-grid-column field="ShipCity" headerText="Ship City" width="130"></e-grid-column>
9+
</e-grid-columns>
10+
</ejs-grid>

ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-menu.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ The default column menu items are displayed in following table.
4040
4141
> 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.
4242
43+
## Prevent column menu for particular column
44+
45+
The Syncfusion<sup style="font-size:70%">&reg;</sup> 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.
46+
47+
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.
48+
49+
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**.
50+
51+
{% tabs %}
52+
{% highlight cshtml tabtitle="CSHTML" %}
53+
{% include code-snippet/grid/columns/prevent-column-menu/razor %}
54+
{% endhighlight %}
55+
{% highlight c# tabtitle="Columnmenu.cs" %}
56+
{% include code-snippet/grid/columns/prevent-column-menu/columnmenu.cs %}
57+
{% endhighlight %}
58+
{% endtabs %}
59+
60+
![Prevent column menu](../images/column-menu/prevent-column-menu.png)
61+
4362
## Add custom column menu item
4463

4564
The custom column menu item feature allows you to add additional menu items to the column menu in the Syncfusion<sup style="font-size:70%">&reg;</sup> 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.

ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-menu.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,25 @@ The default column menu items are displayed in following table.
4242
4343
> 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.
4444
45+
## Prevent column menu for particular column
46+
47+
The Syncfusion<sup style="font-size:70%">&reg;</sup> 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.
48+
49+
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.
50+
51+
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**.
52+
53+
{% tabs %}
54+
{% highlight cshtml tabtitle="CSHTML" %}
55+
{% include code-snippet/grid/columns/prevent-column-menu/tagHelper %}
56+
{% endhighlight %}
57+
{% highlight c# tabtitle="Columnmenu.cs" %}
58+
{% include code-snippet/grid/columns/prevent-column-menu/columnmenu.cs %}
59+
{% endhighlight %}
60+
{% endtabs %}
61+
62+
![Prevent column menu](../images/column-menu/prevent-column-menu.png)
63+
4564
## Add custom column menu item
4665

4766
The custom column menu item feature allows you to add additional menu items to the column menu in the Syncfusion<sup style="font-size:70%">&reg;</sup> 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.
Loading

0 commit comments

Comments
 (0)