Hi

I have had an issue where I want to be able to Sort the Grouping Feature in a grid by a particular order or in other words sort by a column but display another column in the Group name. I have looked through the forums and hadn't found a suitable answer so I thought I would post a solution here that I came up with for anyone else looking.

By default when sorting a Grid with Grouping the sort is applied to the "GroupField" property of the Store. The grouping is sorted by the "GroupDir" property of the Store by either "Asc" or "Desc".

In my example I had groupings of:

1.0 Group 1
2.0 Group 2
3.0 Group 3
.
.
.
10.0 Group 10
11.0 Group 11

However, as the sorting is based on Ascending order of my GroupField and this is converted to text. It appeared in the grid as this:

1.0 Group 1
10.0 Group 10
11.0 Group 11
2.0 Group 2
.
.
.
9.0 Group 9

To correct this I made the following changes. I created a new ModelField which contains my sorting Info which for me is just an Int value of 1 to 11. However this could be anything you like i.e Dates, Id's etc

<ext:ModelField Name="GroupSortOrder" Type="Int" />
Then added a Sorter into my Store
<Sorters>
     <ext:DataSorter Property="GroupSortOrder" />
</Sorters>
Then changed the GroupField on the Store to the new field created:
<ext:Store ID="store" runat="server" GroupField="GroupSortOrder" GroupDir="ASC">

This now has the grouping with the correct sorting. Now I just needed to get the correct text in the GroupHeader and this is provided with the Grouping Summary Feature.

You need to modify the GroupHeaderTplString. There are a number of properties available to you in this template and one of which is the "children" which are the child rows of the group. Simply select the first child row and get the value from the column you want as in below:

<ext:GroupingSummary ID="GroupingSummary1" runat="server" GroupHeaderTplString="{[values.children[0].get('ColumnNameToDisplay')]}" >
Essentially what this means is that you can sort by one column but display another.

Hopefully this should help some people.