I have a RadGrid that gets its data from a stored procedure and the data is already ordered in the desired way. The RadGrid's group by automatically re-orders the group by field by alphabetical order. Is there a way to leave the order of the rows in its initial state? For example, if we're grouping on column X, if B appears before A from the data source, in the RadGrid B would be the first grouping section and A the second.
If not, then is there a way I can sort the group by field by a specific field? For example, this is what I would want to do:
<
GroupByExpressions
>
<
telerik:GridGroupByExpression
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldName
=
"Category"
SortField
=
"ColumnXYZ"
SortOrder
=
"Ascending"
/>
</
SelectFields
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"Category"
/>
</
GroupByFields
>
</
telerik:GridGroupByExpression
>
</
GroupByExpressions
>
Thanks in advance!
Eric
13 Answers, 1 is accepted
To achieve the desired functionality you can handle the SortCommand event of the grid and there implement your logic. Find more information on custom grid sorting in the following resources:
http://www.telerik.com/help/aspnet-ajax/grdapplycustomsortcriteria.html
http://www.telerik.com/help/aspnet-ajax/grdsortingexpressions.html
I hope this gets you started properly.
Greetings,
Pavlina
the Telerik team

http://www.telerik.com/help/aspnet-ajax/grdapplycustomsortcriteria.html
http://www.telerik.com/help/aspnet-ajax/grdsortingexpressions.html
Thanks
You can access the needed articles in the links below:
http://www.telerik.com/help/aspnet-ajax/grid-apply-custom-sort-criteria.html
http://www.telerik.com/help/aspnet-ajax/grid-sorting-expressions.html
All the best,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

I have a same requirement as Eric mentioned. I have multiple Group by Expressions. By default the group By expression is sorted by ascending order, but i have implemented order by Sequence in the retrieving query. i have also mentioned <telerik:GridGroupByField FieldAlias="Desc" FieldName="Desc" SortOrder="None"></telerik:GridGroupByField>, but no use. By default it is order by Ascending order of the description.
I need a working solution as soon as possible.

SortOrder specifies how group values are sorted. Its value can be "Ascending" or "Descending". The default value of the SortOrder property is "Ascending". Setting it to "None" will not affect the order in which the group items are displayed.
Please take a look at this article to know more on Grid Group-by Expression.
Thanks,
Princy

Then what is the solution for my requirement, to be order by Sequence number, not in ascending order.
Example:
Apple seq No- 2
Unit 10
Rate 35
Orange seq No- 1
Unit 20
Rate 25
Unit 10
Rate 15
But Values need to be
Orange seq No- 1
Unit 20
Rate 25
Unit 10
Rate 15
Apple seq No- 2
Unit 10
Rate 35

<SelectFields>
<telerik:GridGroupByField FieldAlias="Desc" FieldName="Desc" SortOrder="None"> </telerik:GridGroupByField>
</SelectFields>

Setting SortOrder is not supported for the 'Select' fields in a 'Group By' expression. If you want to set SortOrder you have to set in the GroupByFields.
ASPX:
<
telerik:GridGroupByExpression
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldAlias
=
"SeqNo"
FieldName
=
"SeqNo"
></
telerik:GridGroupByField
>
</
SelectFields
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"SeqNo"
SortOrder
=
"Ascending"
></
telerik:GridGroupByField
>
</
GroupByFields
>
</
telerik:GridGroupByExpression
>
Thanks,
Princy

I am afraid that there is no way to remove the sorting of the Grouped data. The way the grouping functionality works is it first sorts the data and then it is grouping the data by given field. When the Grouping is performed for the Grid there is no way to understand currently grouped item in which place was before the grouping. And what about if the item was in such order that it now needs to be shown in another Group. This will break the functionality.
Another thing, when you want to perform grouping on a database level you are always forced to ORDER BY before GROUP BY. And we are also performing the grouping operation over the datasource.
Regards,
Pavlina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Searching the same issue and found this year old thread. Coming from a sql server database perspective this workaround below worked for me. Basically provide a virtual unique value from your query for your grid to groupby and sort..but display a group name in the select (sql order by in the sql is ignored going to grid but left for you to observe the results). The key here is the row_number() function that assign a value per record while sorting.
-- sql server,database query, GroupSequence = unique group or sequence ID given at query time
select g.GroupSequence, g.GroupName, sp.SalesPersonID, sp.FirstName, sp.EmailAddress
from dbo.SalesPersons sp
inner join (select row_number() over(order by Sequence, [Description], SalesGroupID) as GroupSequence, SalesGroupID, Description as GroupName from dbo.SalesGroups) g on g.SalesGroupID = sp.SalesGroupID
order by GroupSequence, FirstName
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldName="GroupName"></telerik:GridGroupByField>
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="GroupSequence"></telerik:GridGroupByField>
</GroupByFields>
</telerik:GridGroupByExpression>
​

Hi Pavlina,
I do not know if this is any different. I am bringing data in, in the order of My preference. I tried setting the sort order to None in the groupbyfield. My requirement is to have 'GENERAL" category on the top followed by others departments in ascending order. Please find the attached that shows how it is as of now. It has everything grouped by department in ascending order. I tried setting the sort order to none and so on but nothing seemed to work.
Thank you.
This question has already been discussed in a separate support thread. I suggest to continue the conversation there. The ticket title is "Grouping in order to get a specific record on the top rather than sorting order".
Feel free to let us know any additional comments.
Kind regards,
Tsvetomir
Progress Telerik