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

[Solved] Is there a way to define a "SortField" within a GroupDescriptor?

3 Answers 143 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rob
Top achievements
Rank 1
Rob asked on 16 Oct 2010, 04:31 PM
Let's say I have a dataset and grid defined like this:
ObservableCollection<Priority> ListOfPriorities = new ObservableCollection<Priority>()
{
   new Priority() { Name = "Low", ID = 6, SortOrder = 4 },
   new Priority() { Name = "Medium", ID = 1, SortOrder = 3 },
   new Priority() { Name = "High", ID = 5, SortOrder = 2 },
   new Priority() { Name = "Critical", ID = 3, SortOrder = 1 }
};
  
ObservableCollection<Project> TheList = new ObservableCollection<Project>();
for (int i = 1; i <= 10; i++)
{
   Projectp = new Project()
   {
      ID = 1000 + i,
      Name = Guid.NewGuid().ToString(),
      ProjectPriority = ListOfPriorities[i % 4],
   };
   TheList.Add(p);
}
this.dg.DataContext = TheList;
  
GroupDescriptor gd = new GroupDescriptor()
{
   Member = "ProjectPriority.Name",
   SortDirection = System.ComponentModel.ListSortDirection.Descending,
   DisplayContent = "ProjectPriority.Name",
   MemberType = typeof(string),
   AggregateFunctions = new AggregateFunctionCollection()
   {
      new CountFunction() { Caption = "count=", ResultFormatString = "[{0}]}
   }
};
this.dg.GroupDescriptors.Add(gd);


I would like to be able to set a "SortField" on the GroupDescriptor so that the groups (Project Priorities in this example) would actually be sorted using their SortOrder property (Critical=1; High=2; Medium=3; Low=4) and not their string value but the string value would still be shown as the "Group Name"...  Is something like this possible?


3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 18 Oct 2010, 08:30 AM
Hi Rob,

It is not possible to define a sort field inside the group descriptor. What you can do is define a new SortDescriptor and add it to the SortDescriptors collection of the RadGridView.

Hope this helps.

Best wishes,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rob
Top achievements
Rank 1
answered on 18 Oct 2010, 02:10 PM
Thanks Veselin.  It seems like that will do the trick for now.  I'm just catching the "grouped" event and inserting a sort descriptor...

Although, I would like to request it for a future version if that is possible... It would be nice to NOT have to do that and have some sort of a SortMember on the GroupDescriptor.
0
Veselin Vasilev
Telerik team
answered on 18 Oct 2010, 03:03 PM
Hi Rob,

I spoke with the developers and they said it won't be easy to implement. Still, we will add it in our list for future consideration.

Best wishes,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Rob
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Rob
Top achievements
Rank 1
Share this question
or