SortDescriptors collection of RadGridView is Empty

5 posts, 0 answers
  1. Max
    Max avatar
    4 posts
    Member since:
    Apr 2013

    Posted 22 Apr 2015 Link to this post

    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

     

  2. Max
    Max avatar
    4 posts
    Member since:
    Apr 2013

    Posted 22 Apr 2015 in reply to Max Link to this post

    NB as shown in the example here:

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

     

  3. Max
    Max avatar
    4 posts
    Member since:
    Apr 2013

    Posted 22 Apr 2015 in reply to Max Link to this post

    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
                }
    }

  4. Max
    Max avatar
    4 posts
    Member since:
    Apr 2013

    Posted 22 Apr 2015 in reply to Max Link to this post

    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.
  5. Stefan
    Admin
    Stefan avatar
    1073 posts

    Posted 23 Apr 2015 Link to this post

    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.

     
Back to Top