As shown in the attachment, I have a gridcontrol grouped by Name. If I sort this gridcontrol by height, only items within a group will be sorted.
What I want is, if I sort height, then, groups will be also sorted by height. The height of each first item of the group will be used to sort.
In another word, after I click Height column, the result that I want is:
Name: d ....... Height 18
Name: a ....... Height 19
....... Height 20
Name: b ....... Height 20
Name: e ....... Height 22
Yes, I know that I can code it by myself, I am just curious that if Devexpress has such an option since I need make a couple of columns like this.
Thank you for the question. The current version of XtraGrid doesn't provide a direct way to achieve this goal. Moreover, this is a rather difficult task to implement, and the requested functionality may cause serious performance problems in your application. Let me explain why. To properly group data, the grid should first sort rows against grouped column values. Sorting should be performed based upon two fields - the Name and the Height in your case. Moreover, data should be sorted using a very specific algorithm, so, rows that have the same name should be arranged one after another, but the group of rows should be arranged based upon the Height field value. Finally, there may be some ambiguity with this approach. For example, if a group with name "a" contains rows with the following heights 15, 25 and the group whose name is "b" contains a row whose heigh is between the above mentioned values - 20 for example. With this data the sorting algorithm you described doesn't make sense. That is why we decided not to introduce this approach. In any case, you can implement the requested solution yourself by handling the CustomColumnSort and CustomColumnGroup events. Please refer to the corresponding documentation to learn more on how to accomplish this goal.
[Updated by Uriah (DevExpress Support)]
A possible workaround is create GridGroupSummaryItems, and sort group rows by summary. Attached is a sample project, demonstrating how to implement this.
1. Use the Min summary type, to sort by first values sorted in the ascending order.
2. You can prevent summaries from being displayed in the group row by modifying the GridView.GroupFormat property.
3. Use the GridView.GroupSummarySortInfo property to apply sorting.