This question is locked. New answers and comments are not allowed.
I've got a grid of DataGridTemplateColumns, with GroupHeaderStyle, GroupHeaderTemplate, and a DelegateGroupDescriptor KeyLookup (UserGroupMode="Disabled", so all the grouping is predefined).
The problem appears to be that when the grouping is applied programmatically after the data is populated, the groups are in reverse order compared to the data.
To illustrate, here is what the data looks like before the grouping is applied:
Item 1 / Category A
Item 2 / Category B
Item 3 / Category C
After the grouping (by Category) is applied, I see
----- Category C -----
Item 3
----- Category B -----
Item 2
----- Category A -----
Item 1
There is no explicit sorting defined.
Is there any way to reverse the groups' order?
The problem is further exacerbated by the fact that the original, ungrouped data is displayed in the order it is received, not according to some logical sorting; hence, it would be very difficult to sort the data (e.g. by adding a SortDescriptor) after the grouping is applied.
The problem appears to be that when the grouping is applied programmatically after the data is populated, the groups are in reverse order compared to the data.
To illustrate, here is what the data looks like before the grouping is applied:
Item 1 / Category A
Item 2 / Category B
Item 3 / Category C
After the grouping (by Category) is applied, I see
----- Category C -----
Item 3
----- Category B -----
Item 2
----- Category A -----
Item 1
There is no explicit sorting defined.
Is there any way to reverse the groups' order?
The problem is further exacerbated by the fact that the original, ungrouped data is displayed in the order it is received, not according to some logical sorting; hence, it would be very difficult to sort the data (e.g. by adding a SortDescriptor) after the grouping is applied.
5 Answers, 1 is accepted
0
Hello Yuri,
Thank you for contacting us.
You can change the sort direction of the groups with the SortOrder property of the group descriptor. If you wish to sort the data in the groups, you can add a SortDescriptor to the DataGridTemplateColumn and tap on the header to change the sort order. Another way to sort the data is to add sort descriptors directly to the RadDataGrid.SortDescriptors collection. If you use the grid SortDescriptors collection, please do not forget to clear the descriptors that have been previously added to reset the sort order of the items. I have attached a sample project that demonstrates how you can sort the groups and the items.
I hope this helps. Please, let us know if you have further questions.
Regards,
Rosy Topchiyska
Telerik
Thank you for contacting us.
You can change the sort direction of the groups with the SortOrder property of the group descriptor. If you wish to sort the data in the groups, you can add a SortDescriptor to the DataGridTemplateColumn and tap on the header to change the sort order. Another way to sort the data is to add sort descriptors directly to the RadDataGrid.SortDescriptors collection. If you use the grid SortDescriptors collection, please do not forget to clear the descriptors that have been previously added to reset the sort order of the items. I have attached a sample project that demonstrates how you can sort the groups and the items.
I hope this helps. Please, let us know if you have further questions.
Regards,
Rosy Topchiyska
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.
0
Yuri
Top achievements
Rank 1
answered on 27 Aug 2014, 12:45 PM
Hi Rosy, thank you for your reply.
Unfortunately, while providing somewhat related information, it does not answer my actual question.
What I am interested to know is not how to apply any kind of sorting, but rather how to have the groups shown in the same order in which their respective items were added - and not in the reverse order.
If I apply SortOrder (ascending or descending), the group headers will be sorted alphabetically.
As I mentioned in my original post, that is not what I am looking for; neither am I interested in implementing any custom SortDescriptors (because this would require adding some superfluous ordinal property to my data).
My hunch is that when the grouping is applied, each new group - when it's being identified and added - is injected in the beginning of the groups list, instead of in the end. If this is the case, I would like to see a way to reverse this.
Thank you.
Unfortunately, while providing somewhat related information, it does not answer my actual question.
What I am interested to know is not how to apply any kind of sorting, but rather how to have the groups shown in the same order in which their respective items were added - and not in the reverse order.
If I apply SortOrder (ascending or descending), the group headers will be sorted alphabetically.
As I mentioned in my original post, that is not what I am looking for; neither am I interested in implementing any custom SortDescriptors (because this would require adding some superfluous ordinal property to my data).
My hunch is that when the grouping is applied, each new group - when it's being identified and added - is injected in the beginning of the groups list, instead of in the end. If this is the case, I would like to see a way to reverse this.
Thank you.
0
Hello Yuri,
Sorry for the misunderstanding.
By default the groups are sorted by they key property. I have attached a sample project where I have added a property to your data class that is set when a new data item is added to the items collection and it keeps the actual group key (the order in which the item is added). This property is used when grouping the items but the group headers display the corresponding value.
I hope this helps. Please, let us know if you have any other questions.
Regards,
Rosy Topchiyska
Telerik
Sorry for the misunderstanding.
By default the groups are sorted by they key property. I have attached a sample project where I have added a property to your data class that is set when a new data item is added to the items collection and it keeps the actual group key (the order in which the item is added). This property is used when grouping the items but the group headers display the corresponding value.
I hope this helps. Please, let us know if you have any other questions.
Regards,
Rosy Topchiyska
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.
0
Yuri
Top achievements
Rank 1
answered on 16 Sep 2014, 03:13 PM
Hi Rosy, and thank you for this example.
It does look closer to what I am trying to achieve, yet there is still one difference.
In your example, you define the PropertySortDescriptor on the single column there is, in the expectation of that column's being used for grouping.
What I have is a grid with multiple columns, and UserGroupMode="Disabled". The grouping is done by defining
<telerikGrid:RadDataGrid.GroupDescriptors>
<telerikGrid:DelegateGroupDescriptor>
<telerikGrid:DelegateGroupDescriptor.KeyLookup>
<gui:ResultByParentResultSetGroupKeyLookup/>
</telerikGrid:DelegateGroupDescriptor.KeyLookup>
</telerikGrid:DelegateGroupDescriptor>
</telerikGrid:RadDataGrid.GroupDescriptors>
on the grid itself, not on any particular column (and as a matter of fact the grouping criteria are not based on any of the data displayed in the columns at all, but rather on some logical "metadata").
I would greatly appreciate it if you could provide an example that works in my particular setup.
What I already added to the code is the logic that assigns the incremental OrdinalNumber property to each dataset when it is added to the aggregated data. I suppose this property can be used for sorting, to show the groups (corresponding to these datasets) in the order in which they were added to the aggregation.
Thank you!
It does look closer to what I am trying to achieve, yet there is still one difference.
In your example, you define the PropertySortDescriptor on the single column there is, in the expectation of that column's being used for grouping.
What I have is a grid with multiple columns, and UserGroupMode="Disabled". The grouping is done by defining
<telerikGrid:RadDataGrid.GroupDescriptors>
<telerikGrid:DelegateGroupDescriptor>
<telerikGrid:DelegateGroupDescriptor.KeyLookup>
<gui:ResultByParentResultSetGroupKeyLookup/>
</telerikGrid:DelegateGroupDescriptor.KeyLookup>
</telerikGrid:DelegateGroupDescriptor>
</telerikGrid:RadDataGrid.GroupDescriptors>
on the grid itself, not on any particular column (and as a matter of fact the grouping criteria are not based on any of the data displayed in the columns at all, but rather on some logical "metadata").
I would greatly appreciate it if you could provide an example that works in my particular setup.
What I already added to the code is the logic that assigns the incremental OrdinalNumber property to each dataset when it is added to the aggregated data. I suppose this property can be used for sorting, to show the groups (corresponding to these datasets) in the order in which they were added to the aggregation.
Thank you!
0
Hello Yuri,
I have modified the project from my previous answer - now the grouping is not related to any column. Could you please take a look and see if this is works for you.
I hope this helps.
Regards,
Rosy Topchiyska
Telerik
I have modified the project from my previous answer - now the grouping is not related to any column. Could you please take a look and see if this is works for you.
I hope this helps.
Regards,
Rosy Topchiyska
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.