We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Custom context menu problem with CustomContextMenuItems class

Hello. I'm trying to follow the doc to make a custom context menu on a asp.net MVC Grid control.

However, it seems like I can't resolve the class CustomContextMenuItems

    .ContextMenuSettings(contextMenu =>
    {
        contextMenu.EnableContextMenu()
            .CustomContextMenuItems(new List<CustomContexMenuItems>() { new CustomContexMenuItems() { Id = "MyMenu", Text = "MyMenuItem" } }); // CustomContext menu items

    })

I get the error
 CS0246: The type or namespace name 'CustomContexMenuItems' could not be found (are you missing a using directive or an assembly reference?)

1 Reply

MS Mani Sankar Durai Syncfusion Team May 23, 2017 10:15 AM UTC

Hi Jonathan, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and based on requirement we have prepared a sample that can be downloaded from the below link. 
Refer the code example. 
@(Html.EJ().Grid<MvcApplication14.OrdersView>("FlatGrid") 
                .Datasource((IEnumerable<object>)ViewBag.data) 
                  .AllowPaging() 
                
                       .ContextMenuSettings(contextMenu => 
                { 
                    contextMenu.EnableContextMenu(); 
                    contextMenu.CustomContextMenuItems(new List<Syncfusion.JavaScript.Models.CustomContexMenuItems>() { 
                    new Syncfusion.JavaScript.Models.CustomContexMenuItems() { Id = "MyMenu", Text = "MyMenuItem" } , 
 
                    }); 
                }) 
        .Columns(col => 
        { 
... 
        }) 
         
) 
 
 

If you are mentioning the class name alone we suggest you refer the corresponding namespace in Razor page. 
Refer the code example. 
@using Syncfusion.JavaScript.Models; 
@(Html.EJ().Grid<MvcApplication14.OrdersView>("FlatGrid") 
                ... 
                       .ContextMenuSettings(contextMenu => 
                { 
                    contextMenu.EnableContextMenu(); 
                    contextMenu.CustomContextMenuItems(new List<CustomContexMenuItems>() { 
                    new CustomContexMenuItems() { Id = "MyMenu", Text = "MyMenuItem" } , 
 
                    }); 
                }) 
        .Columns(col => 
        { 
        }) 
         
) 

The issue is due to DLL Conflict. To avoid this issue, please make sure the following things before build your application. 
1.       Check if multiple versions of Syncfusion assemblies are referred in your project. 
2.       Delete bin and obj folders exists in the application directory. 
3.       Check your dll version in reference and web.config file 
4.       Check if you are referring proper dependent assemblies according to the .NET Framework.  
 
Refer the documentation link: 
 
 
Regards, 
Manisankar Durai. 
 
  
 
 
 


Loader.
Up arrow icon