I'm trying to sort a datagrid that has its data source set to 'Association' of a parent object. But I can't. The ability to sort is only available to me if I select Database or XPath as a data source. I understand from this post https://forum.mendix.com/link/questions/4052 that it's because I'm potentially sorting on committed and uncommitted objects, but the post also seemed to indicate that this was a feature that could be implemented. Well, four years later it looks like it still hasn't been implemented. I've tried using a microflow as the data source and doing the sort inside the microflow first but then I'm unable to go any further because Mendix won't allow me to edit fields from a microflow data source. Is there a way for me to sort an association datagrid?
To the best of my knowledge; no there isn't.
From database = you can set sort order
From datasource microflow = you can sort the items in the microflow before returning them
Over association = you take it as it comes
The association data source is intended as an optimal solution for a specific use case, specifically if you want a light-weight overview of associated data. Stuff like sorting and editing undermine that goal, which is why they were never implemented.
For more complex and flexible solutions, the Xpath source is usually recommended. I'm sort of assuming you have a good reason for not going that route, or you wouldn't be here, but without the particulars it's hard to deliver a definitive solution.
On the surface the Xpath source seems to cover all your bases. The entity selector will allow you to mimic anything you can build with the Association source, which you can extend as much as you want if you don't mind customizing the xpath query yourself. Additionally, xpath sources support pretty much every feature the data grid has, including the ones you've mentioned.