Which event fires when sorting DESC (by clicking on header twice)

I want to capture the event when sorting changes, and I was using mygridsortingcontrol.TableDescriptor.SortedColumns.Changed, but that doesn't fire when the direction changes, only when the column is added or removed from the sortedcolumns collection.


What event fires when a Sort is added, changed or removed

1 Reply

AR Arulpriya Ramalingam Syncfusion Team December 7, 2017 10:41 AM UTC

Hi David,   
   
Thanks for contacting Syncfusion support.   
   
By default, the SortedColumns.Changed event will trigger whenever the SortedColumns are added, changed (i.e. the direction of sorting), removed the columns and refreshed (i.e. the sort columns are changed). This can be restricted for particular action based on conditions by using the Action property and the direction of the sorted column can be retrieved by using the SortDirection property of SortColumnDescriptor. Please make use of below code and sample,   
   
Code example   
   
//Event triggering   
this.gridGroupingControl1.TableDescriptor.SortedColumns.Changed += SortedColumns_Changed;   
   
//Event customization   
private void SortedColumns_Changed(object sender, ListPropertyChangedEventArgs e)   
{   
    if ((e.Action == ListPropertyChangedType.ItemPropertyChanged || e.Action ==ListPropertyChangedType.Add ||   
        e.Action == ListPropertyChangedType.Refresh || e.Action ==ListPropertyChangedType.Remove)   
        && e.Item is SortColumnDescriptor)   
    {   
        //to get the sort column descriptor   
        SortColumnDescriptor sortColumn = e.Item as SortColumnDescriptor;   
        //Action for descending sorting   
        if(sortColumn.SortDirection == ListSortDirection.Descending)   
        {   
            //Code to your customization   
        }   
        MessageBox.Show(sortColumn.SortDirection.ToString());   
    }   
}   
   
   
   
   
Regards,   
Arulpriya   


Loader.
Up arrow icon