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

[Solved] Sorting within a group

3 Answers 328 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 14 Aug 2007, 12:19 AM
I have created a report with a group in it:
  group1.Grouping.Add(new GroupExpression("id1"));

When I run the report the data comes out in the groups I would expect, eg
Group1
  data
Group2
  data
Group3
  data

I then add a sort expression:
  group1.Sorting.Add(new SortExpression("id2"));

and now when I run the report I get fragmented groups:
Group1
  data
Group2
  data
Group1
  somemore data
Group3
  data
Group2
  somemore data

How do I correctly sort data within a group?

3 Answers, 1 is accepted

Sort by
0
Svetoslav
Telerik team
answered on 14 Aug 2007, 10:47 AM
Hi Rob,

Please try sorting the group1 data by both id1 and id2, in this order:

group1.Sorting.Add(new SortExpression("id1"));
group1.Sorting.Add(new SortExpression("id2"));


 
Sincerely yours,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rob
Top achievements
Rank 1
answered on 15 Aug 2007, 02:59 AM
Hi Svetoslav,
That didn't appear to work. The second sorting expression seemed to be ignored.

What is interesting is that if I swap the sorting expressions around then it sorts the whole list first and then groups it. This seems to be strange behaviour as I'm adding the SortExpression to the group's Sorting collection - I would have expected any SortExpression to be local to the group and not the report - is my understanding correct?

Thanks,
Rob
0
Accepted
Svetoslav
Telerik team
answered on 16 Aug 2007, 11:38 AM
Hi Rob Johnston,

It is true that the current version exhibits some unexpected behavior when combining the sort functions on report and group levels. This problem is already fixed for the upcoming version the next month.

For now it would be best to use only the sorting on the whole report:

myReport.Sorting.Add(new SortExpression("id1"));
myReport.Sorting.Add(new SortExpression("id2"));

 
Sincerely yours,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Rob
Top achievements
Rank 1
Answers by
Svetoslav
Telerik team
Rob
Top achievements
Rank 1
Share this question
or