Thank you for writing.
I am glad that you have found a suitable solution for your specific case. However, note that when you programmatically add SortDescriptors
, the SortChanging
events are also fired. The SortChanging
event is raised before the data is sorted. In the event handler the RadGridView.SortDescriptors
collection is not updated yet as this is a cancelable event. If you need to clear the SortDescriptors
collection, it is more suitable to use the SortChanged
event when the sorting operation has already finished. Please refer to the following code snippet demonstrating how to manipulate the SortDescriptors
collection avoiding an infinite loop and add programmatically a new SortDescriptor
sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)
.radGridView1.SortChanged -= radGridView1_SortChanged;
//add SortDescriptors according to your requirement
Telerik.WinControls.UI.GridViewTemplate gwt = (Telerik.WinControls.UI.GridViewTemplate)sender;
Telerik.WinControls.Data.SortDescriptor sort = (Telerik.WinControls.Data.SortDescriptor)e.NewItems;
Telerik.WinControls.Data.SortDescriptor sort1 =
, Direction = System.ComponentModel.ListSortDirection.Ascending
.radGridView1.SortChanged += radGridView1_SortChanged;
Feel free to modify the code snippet on a way to achieve the desired behavior.
I hope this information helps. Should you have further questions I would be glad to help.
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal
and vote to affect the priority of the items