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
close icon

GridTemplateColumn will not show ContextMenu

How do I get the ContextMenu to show in a SfDataGrid using a GridTemplateColumn and the grids EditTrigger is set to OnTap? If I set it to DoubleTap the menu will show. I want the same functionality setting the EditTrigger to OnTap.


1 Reply

SP Shobika Palani Syncfusion Team April 28, 2017 12:22 PM UTC

Hi Andy, 

Thank you for contacting Syncfusion Support. We have analyzed your query. Seems you are looking to show context menu of the element inside EditTemplate. You can achieve your requirement by overriding GridCurrentCellManager as like below code snippet 

Code Example: 

this.datagrid.SelectionController = new SelectionControllerExt(this.datagrid); 
 
public class CurrentCellManager : GridCurrentCellManager 
    { 
    
        public CurrentCellManager(SfDataGrid grid) : base(grid) 
        {  
        } 
 
        internal  void SetSuspendAndResumepdates(Action suspendupdates, Action resumeupdates) 
        { 
            SuspendUpdates = suspendupdates; 
            ResumeUpdates = resumeupdates; 
        } 
       
        public override void ProcessOnTapped(MouseButtonEventArgs e, RowColumnIndex currentRowColumnIndex) 
        { 
            if (dataGrid.EditTrigger == EditTrigger.OnTap && e.ChangedButton != MouseButton.Right) 
                base.ProcessOnTapped(e, currentRowColumnIndex); 
 
            if (CurrentRowColumnIndex == currentRowColumnIndex) 
            { 
                if (!(this.dataGrid is DetailsViewDataGrid)) 
                    ScrollInView(currentRowColumnIndex); 
            } 
        } 
    } 
 
    public class SelectionControllerExt : GridSelectionController 
    { 
        public SelectionControllerExt(SfDataGrid dataGrid) : base(dataGrid) 
        { 
        } 
 
        protected override GridCurrentCellManager CreateCurrentCellManager() 
        { 
            CurrentCellManager currentcellmanager = new CurrentCellManager(DataGrid); 
            currentcellmanager.SetSuspendAndResumepdates(SuspendUpdates,ResumeUpdates); 
            return currentcellmanager; 
        } 
    } 

Please let me know, if your requirement is different from above scenario. 

Thanks, 
Shobika P 


Loader.
Live Chat Icon For mobile
Up arrow icon