- Home
- Forum
- Xamarin.Forms
- group and sort data by date, and calculate total amounts by month
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
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
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
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.
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
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
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
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
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.
- 8 Replies
- 3 Participants
- Marked answer
-
UN Unknown
- Oct 29, 2024 05:58 PM UTC
- Nov 5, 2024 10:16 AM UTC