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

How to Customize ordering group in RadGridView

1 Answer 29 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rafael
Top achievements
Rank 1
Rafael asked on 19 Mar 2014, 03:29 PM
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.

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 24 Mar 2014, 12:03 PM
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.

 
Tags
GridView
Asked by
Rafael
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or