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

Hide context menu when sorting is applied by CustomAdaptor


I want to hide context menu when sorting is applied.
I'm using CustomAdaptor and implemented method ReadAsync(DataManagerRequest dm, string key = null) to get data filtered and paged.
I also can check inside that method if (dm.Sorted != null) and so on.
But I can't manipulate with any other grid settings, or ContextMenuItem from there.

1 Reply

RS Renjith Singh Rajendran Syncfusion Team December 19, 2019 10:27 AM UTC

Hi Dan, 

Thanks for contacting Syncfusion support. 

We suggest you to bind the “OnActionComplete” event to Grid, and in the event handler based on the “RequestType” and “ColumnName” modify the value of  ContextMenuItems property of Grid. We have prepared a sample based on this requirement, please download the sample form the link below, 

Please use the code below, 

<EjsGrid TValue="Order" ID="Grid" AllowSorting="true" AllowFiltering="true" AllowPaging="true" ContextMenuItems="@ContextItems"> 
    <GridEvents OnActionComplete="OnActionComplete" TValue="Order"></GridEvents> 
    <EjsDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></EjsDataManager> 
    public static List<Order> Orders { get; set; } 
    public List<object> ContextItems = new List<object>() { "AutoFit", "AutoFitAll", "SortAscending", "LastPage", "NextPage"}; 
   public void OnActionComplete(ActionEventArgs<Order> args) 
        if(args.RequestType.ToString() == "Sorting") 
            if(args.ColumnName != null) 
                ContextItems = new List<object>() { };    //Empty the context items if the column is sorted, so that context menu wont open           
                ContextItems = new List<object>() { "AutoFit", "AutoFitAll", "SortAscending", "LastPage", "NextPage"}; 

Please get back to us if you need further assistance. 

Renjith Singh Rajendran. 

Live Chat Icon For mobile
Up arrow icon