group and sort data by date, and calculate total amounts by month

Hello, I have a sfdatagrid that includes 2 columns: the first contains a date, the second an amount in euros. I would like a display that groups the lines with the same month of the same year. On the group separation line, I would like to see the date with a MMMM yyyy format and also the total amounts of the month. And finally, the groups should appear sorted by date order. The data comes from a SQLite table containing the date and the amount. In my app, everything works except that the groups are not sorted correctly by date. Please help me find a solution to this problem. Many Thanks


Attachment: HistPaniers_da2fb51a.zip

8 Replies 1 reply marked as answer

SD Sethupathy Devarajan Syncfusion Team October 30, 2024 12:07 PM UTC

Hi Marcel,

 

From the provided XAML, .cs, and model class files, we created a simple sample. In this sample, we modified the data source to use a dummy collection instead of a database. We have achieved the functionality described in your query in the attached sample.

 

If there are any misunderstandings or if your requirements differ, please provide additional details about your use case. Including more information about the expected behavior will help us better understand your needs and provide an appropriate solution.


Regards,
Sethupathy D.


Attachment: XamarinBehaviouSolution_fb3bf324.zip


UN Unknown October 31, 2024 03:24 PM UTC

Hello, thank you for your answer, and your solution works very well with your data, but not properly with mine. It seems that the classification is correctly done by year, but in the same year, the order is that of entry. I don't understand because the sortedList is classified correctly on the GroupKey. I specify that the system language is fr-FR. I'm attaching the complete code of the app, so that you can check for yourself this abnormal operation. And thank you again for your help.


Attachment: MemoCourses_9e22378a.7z


UN Unknown October 31, 2024 05:42 PM UTC

Hello, 

I understood where the problem comes from: the classification of the groups is done on:
1. Year
2. The month But expressed by its name (January, February...) and not by its number (1,2,3...)
So the classification of the groups in the same year is done in alphabetical order of the months. How to have a display of the month in the group by name, but the ranking in order of its number. 

Thank you for your help.



AP Abinesh Palanisamy Syncfusion Team November 1, 2024 11:56 AM UTC

Hi Marcel,


Based on the information provided, it seems that you would like to group the data by date and sort the collection in alphabetical order by month. We have prepared a simple sample to demonstrate this required behavior. We have included a sample for your reference. Please review it for further details


If there are any misunderstandings regarding your requirements, or if your needs differ, could you clarify whether you want to achieve multi-level grouping by year and month, with the months sorted alphabetically within their respective year groups? Additionally, how do you intend to maintain the column for achieving this grouping?.


Please provide specific and clear details about the expected behavior for the detailed view. This additional information will help us thoroughly address your request and provide an appropriate solution.


Regards,

Abinesh P


Attachment: SfDataGrid_ac88cdd7.zip


UN Unknown November 1, 2024 02:08 PM UTC

Hello, excuse me for the confusion: I would like the groups to be classified in order of month of the calendar (January, February, March...). Here's an example:

2023 June                       8.30
2023 August                  5.50
2023 September           67.60
2023 October                11.00
2023 December            9.30
2024 August                  9.00

I am enclosing 2 screenshots: the first is the one obtained with your modification, the 2nd is what I would like to get. Thank you again for your help.


Attachment: Orders_105a14fd.zip


SD Sethupathy Devarajan Syncfusion Team November 4, 2024 12:48 PM UTC

Hi Marcel,

 

You would like the group to be classified in calendar month order. We have implemented your request using custom sorting and a converter for grouping. A sample has been shared for your reference.

 

Best regards,

Sethupathy D.


Attachment: SfDataGrid_ac88cdd7_148c2fed.zip

Marked as answer

UN Unknown November 4, 2024 06:03 PM UTC

Hello, 

I had to adapt the solution you proposed to me, because my app is intended for Android, and not for Windows. But after adaptation, it works perfectly! That's exactly what I wanted. 

I thank you for the time you have spent helping me and I am very grateful. You are the best technical support I know. 

Thank you again very much!

Marcel



SD Sethupathy Devarajan Syncfusion Team November 5, 2024 10:16 AM UTC

Hello Marcel,


We’re glad to hear that the adapted solution worked perfectly for your Android app! Your kind words mean a lot, and we're always here to help.


Thanks again, and best of luck with your project!


Regards,
Sethupathy D.


Loader.
Up arrow icon