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

How to detect which header is clicked on

I wish to add context sensitive menu to a right click event on a header, and therefore need to know which column header was clicked on.

In other words: Right clicking on a header should result in executing code that includes some information somewhere on which column header was clicked on.

Is this possible?

Thank you.

1 Reply

JG Jai Ganesh S Syncfusion Team December 2, 2016 11:45 AM UTC

Hi David, 
You can achieve your requirement for adding the context menu in column header and will get the details of the column header like below, 
                    <MenuFlyoutItem Text="Sort Ascending" Command="{Binding Path=DataContext.SortAscendingCommand}" CommandParameter="{Binding}" /> 
private DelegateCommand _sortAscendingCommand; 
public DelegateCommand SortAscendingCommand 
        if (_sortAscendingCommand == null) 
            _sortAscendingCommand = new DelegateCommand(CanSortAscending, SortAscending); 
        return _sortAscendingCommand; 
    set { _sortAscendingCommand = value; } 
private void SortAscending(object param) 
    if (param is GridColumnContextMenuInfo) 
        var grid = (param as GridContextMenuInfo).DataGrid; 
        var column = (param as GridColumnContextMenuInfo).Column; 
        grid.SortColumnDescriptions.Add(new SortColumnDescription() { ColumnName = column.MappingName, SortDirection = ListSortDirection.Ascending }); 
Jai Ganesh S 

Live Chat Icon For mobile
Up arrow icon