How to Customize ordering group in RadGridView

2 posts, 0 answers
  1. Rafael
    Rafael avatar
    15 posts
    Member since:
    Jun 2013

    Posted 19 Mar 2014 Link to this post

    Hi Telerik's Team,

    I need to group data in RadGridView by Type field  from my object. This works!!!
    But I dont wanna to sort that groups ascending or descending. I need to sort by another field: OrderType.

    I am using GroupDescriptor to do this. Like below:

    <telerik:RadGridView x:Name="radGridView" >
                <telerik:RadGridView.GroupDescriptors>
                      <telerik:GroupDescriptor Member="Type" >
                       </telerik:GroupDescriptor>
                 </telerik:RadGridView.GroupDescriptors>
    </telerik:RadGridView >
    ...
    GroupDescriptor descriptor = new GroupDescriptor();
    descriptor.Member = "Type";
    this.radGridView.GroupDescriptors.Add(descriptor);
    this.radGridView.SelectedItem = null;
    this.radGridView.Rebind();
    ...

    But , this way sort by alphabetical order. The GroupDescriptor doesn't have a property to indicate the field used to sort the groups.
    So, I created a new field ( OrderTypeName ) that equals a number concatenated with the Type field.

    Example: 1 - FirstGroup, 2 - SecondGroup, 3 - ThirdGroup, 4 - FourthGroup ...

    My wish is to mantain that sequence (FirstGroup, SecondGroup, ThirdGroup,..) but without use the numbers (1,2,3,...) ahead from Type field  because the numbers can't be displayed in the RadGridView's groups . 

    In other words, I wanna to group by Type field and sort it by OrderType field.

  2. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 24 Mar 2014 Link to this post

    Hi Rafael,

    You can try to achieve the desired functionality using IComparable interface. You can check some sample code on our Custom Sorting with IComparable Online Demo. Then you will set the SortMemberPath property of your column to be "OrderType ". In this way, the grid will use the OrderType property for sorting. And since it is a IComparable<T>, you can tell which string is bigger or smaller than another string.

    Regards,
    Yoan
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  3. DevCraft banner
Back to Top