I have a xamdatagrid with following colums
Col1. (String type)
Col2 (double type)
Add col1 to groupby and col2 has sum aggregation.
When I do sorting on col1, it should sort on col1 data. But when I sort on col2, first it should sort on summary (sum values of col2) and then col2 actual values and it should not sort on group by column (col1) values.
1. Could some post sample code to achieve this.
2. How can I remove "(.. Item)" text from group by cell value
3. How to get group by text and summary value into one row and able to resize summary value cell when col2 is resized?
Thanks in advance.
Hello,
Thank you for your post. I have been looking into it and I suggest you see this forum thread:
http://forums.infragistics.com/forums/p/51696/269950.aspx
a similar issue like yours is discussed.
Hope this helps you.
Thank you.
I did came across the link that link before. I am new to xamdatagrid and was not able to implement as mentioned in the post.
It would be great if you can upload sample c# solution.
I have created a sample project for you where the group by sorting depends on the summary value, but the sorting is evaluated when you click the grouped column.
Thanks for your quick response.
But I want to do sorting on none group column.
Is there a way we can do sorting only on none group by column ?
In your example, I want to group by abbreviation column and do sorting only on ID (with sum summary) column. Result should sort first on ID column summaries and then ID column actual data.
Is this possible?
You can handle the Sorted event of the XamDataGrid and add the following code in the handler:
if (e.Field.Name == "ID") { e.FieldLayout.SortedFields.Add(new FieldSortDescription("Abbreviation", e.SortDescription.Direction, true)); }
I've implemented the code in attached sample. This might be helpful to other members in the forum.
Looks like its working fine with few tweeks.
In the code I've implemented..
1. sotring incase more than one group by selected.
2. If no group by it should do regular sorting
3. If group by column is non numeric and sorting column is numeric (with summary), then it should sort on numueric summary
4. if group by column is numeric and sorted on same column, it should sort on summary of that column
5. As we are adding items to SortedFileds, some times sorting image exsit in column Header even if we are not sorting on that column. To fix this, I am clearing sorting columns in Sorting event and adding valid columns to SortedFileds
In the example (with 12 data rows), if I add Abbrevation and Abbrevation1 columns to group, try sorting on ID, sometimes I see performance hit.
Can you check the code and see if I am doing correct or not?
Any hints on performance?
I have been looking into your sample and I can say that since once you add a FieldSortDescription to the SortedFields collection you are not able to modify it and you want to sort always on the summary values of the first grouped column no matter which one you clicked, the best approach is like you did and clear the sorted fields and add them again, which is a time consuming operation and this is why you have a performance hit.