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

grid with grouping reorders my dataset

5 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ra00l
Top achievements
Rank 1
ra00l asked on 21 Nov 2012, 12:24 PM
Hey guys,

I have a radgrid with grouping enabled. The data source I use for the grid comes sorted from the db, using a more complicated algorithm.

However, the radgrid re-sorts my data, messing up the initial order.

Any ways to prevent that?

PS: I am using version 2012.2.904.40

Thanks!

5 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 26 Nov 2012, 09:53 AM
Hello Raul,

Note that by default RadGrid does not set any sorting on its data. However, when data is grouped, sort order for the groups is applied. This is expected because RadGrid needs to know how to order the groups.

You can still sort the items in a group by using the RadGrid's sorting feature.

I hope this helps.

Kind regards,
Martin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
ra00l
Top achievements
Rank 1
answered on 26 Nov 2012, 09:59 AM
I can't re-sort the data unless I make another query to the db, which will affect performance.

Is there way to prevent grid's sorting when grouping?
Will you add this in future versions? I don't want to add a hack now that will complicate the code, and will be deprecated in a few months, when the new version is out.
0
Martin
Telerik team
answered on 26 Nov 2012, 12:02 PM
Hello,

Simply put, you can not disable sorting of the groups. Groups are always sorted either Ascending (default) or Descending. It does not make sense to have unsorted groups because in this case RadGrid would not know the order in which to render the groups - which group (and its items) to render first, which second and so on. For example lets say we have the sample data bellow:



If we group by Field1 and sort by Field2, two separate groups will be created. However if the groups are not sorted, how do you expect RadGrid to decide which of the 2 groups (and items) to be rendered as a first group (item)? I hope you agree that rendering groups on random basis does not sound very seriously.

As I stated in my previous post groups sorting does not affect sorting of the items in a separate group. Groups sorting is always first and them items sorting inside each group can be performed. It does not make sense to have items sorted first because grouping would eventually rearrange them based on the chosen group by expression.

Greetings,
Martin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
ra00l
Top achievements
Rank 1
answered on 26 Nov 2012, 12:13 PM
Martin, thanks for taking time to read through my issue, and answer.

Here's the issue I'm facing. Maybe you have some ideas to come around it

When I execute my query, here's what's returned from the db, in the RIGHT order: 

Group 1  | Group 2 | Item
-------------------------------------------
item 2 | item 2.1 | item 2.1.1
item 2 | item 2.2 | item 2.2.1
item 3 | item 3.1 | item 3.1.1
item 1 | item 1.1 | item 1.1.1
item 1 | item 1.2 | item 1.2.1
item 1
| item 1.3 | item 1.3.1

When I group by "Group 1" and "Group 2" columns, RadGrid changes the order of the "Group 1" column to "item 1","item 2" and "item 3".
What I want is to keep the initial order, "item 2","item 3" and "item 1".

Is there any way to do this using RadGrid's properties?

0
Martin
Telerik team
answered on 29 Nov 2012, 07:23 AM
Hello,

Unfortunately, RadGrid does not support custom sorting of its groups. For performance optimization purposes, the control first sorts the items by the field you want to group and then builds the groups. This way the groups are always sorted by the field they are build on.

Greetings,
Martin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
ra00l
Top achievements
Rank 1
Answers by
Martin
Telerik team
ra00l
Top achievements
Rank 1
Share this question
or