Completed
Last Updated: 12 Jun 2014 06:06 by ADMIN
ADMIN
Julian Benkov
Created on: 26 Apr 2012 04:38
Category: GridView
Type: Feature Request
1
IMPROVE. RadGridView - clear column sorting using third click on column header
A few threads have been posted over the years to ask about natural sorting, which is clicking a column header to go Ascending, Descending, then back to the default unsorted mode on the third click. I looked around for a tri-state or three-state toggle and didn't find any info.  Very helpful but incomplete info is found here and here, so I thought I'd provide C# code to help anyone else looking to do this. Some threads refer to MasterGridViewTemplate.AllowNaturalSort but that property no longer exists. My code is adapted from the second forum posting referenced. It looks like the library has changed since Sean wrote his code.

Telerik.WinControls.Data.SortDescriptor.Direction is of type System.ComponentModel.ListDirection, and that enum only has two values. So the Boolean _sorted is used - if the grid is sorted in ascending or descending order, then use the sort order, but  if we click past descending order, set _sorted to false (natural sort!) and clear the SortDescriptors.

Of course clearing SortDescriptors means this only works with single column sorting. Maybe someone will follow-up here with a solution that works with multiple columns.
0 comments