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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Hide context menu when sorting is applied by CustomAdaptor

Thread ID:

Created:

Updated:

Platform:

Replies:

150032 Dec 18,2019 11:58 AM UTC Dec 19,2019 10:27 AM UTC Blazor 1
loading
Tags: Grid
Dan Cheremisinov
Asked On December 18, 2019 11:58 AM UTC

Hi 

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.


Renjith Singh Rajendran [Syncfusion]
Replied On 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> 
    ... 
</EjsGrid> 
 
@code{ 
    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           
            } 
            else 
            { 
                ContextItems = new List<object>() { "AutoFit", "AutoFitAll", "SortAscending", "LastPage", "NextPage"}; 
            } 
        } 
    } 
    ... 
} 


Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon