This is a migrated thread and some comments may be shown as answers.

SortDescriptors collection of RadGridView is Empty

4 Answers 151 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Max
Top achievements
Rank 1
Max asked on 22 Apr 2015, 10:12 AM

We have a grid where we have enabled custom sorting and have hooked into the OnGridSorting event. This is getting called when someone clicking on a column header to sort it, as expected. However, the grid's SortDescriptors collection is null.

 I would like to be able to add a SortDescriptor for the column that is being sorted that uses an expression, if it's a particular type of data. However, the collection is empty, which suggests there is a problem.

 Thanks.

Max

 

4 Answers, 1 is accepted

Sort by
0
Max
Top achievements
Rank 1
answered on 22 Apr 2015, 10:13 AM

NB as shown in the example here:

http://docs.telerik.com/devtools/silverlight/controls/radgridview/sorting/how-to/generic-descriptor

 

0
Max
Top achievements
Rank 1
answered on 22 Apr 2015, 10:22 AM

Actually the collection is empty. Not null:

private static void OnGridSorting(object sender, GridViewSortingEventArgs e)
 {
            
            TelerikBoundColumnGridView gridView = sender as TelerikBoundColumnGridView;
 
            if (gridView.SortDescriptors != null)
            {
                      // SortDescriptors collection is empty, but GridViewSortingEventArgs has info about the column being sorted
            }
}

0
Max
Top achievements
Rank 1
answered on 22 Apr 2015, 10:43 AM
Typically, I've just discovered I can do what I need to do. However, I'm still curious to know why there are no SortDescriptors already set up.
0
Stefan
Telerik team
answered on 23 Apr 2015, 01:17 PM
Hi Max,

The described behavior would be expected since you have subscribed to the Sorting event of RadGridView. This event is raised just before the control is being sorted, so the corresponding SortDescriptor is not yet added to the SortDescriptors collection. If you subscribe to the Sorted eventwhich is raised just after RadGridView is sorted, you will notice that the SortDescriptor is already added to the SortDescriptors collection.

Please check our documentation on Sorting events for further reference.

Best Regards,
Stefan
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
GridView
Asked by
Max
Top achievements
Rank 1
Answers by
Max
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or