I'd like to perform sorting/filtering on the data source level. How can I accomplish that? Can I subscribe to some events or provide some special collection view for this purpose?
Hello,
Thank you for your post. I have been looking into it and I suggest you use the following code:
ICollectionView collectionView = CollectionViewSource.GetDefaultView(data);
Where the “data” is an ObsevableCollection<T> e.g. and after you do that you can add SortDescriptions to the “collectionView” object and set it as a DataSource of the XamDataGrid. Please let me know if this helps you or you need further clarifications on this matter.
Looking forward for your reply.
Hi Stefan,
Thanks for your reply.
When saying "on the data source level" I meant that I need to perform sorting in the database. My application in this case is a classic 3-tier application where all my data operations, like sorting, grouping, paging must be delegated to data source layer. I don't want to do anything data-related "in memory". Out-of-the-box sorting of default CollectionView does not work for me.
I've tried implementing ICollectionView interface and supplying it as a data source for XamDataGrid. I was expecting that when I click any column in the grid for sorting, SortDescriptions collection in my ICollectionView would be modified and I could perform sorting through my data access layer and fill collection with new data. Unfortunately it seems like XamDataGrid does the sorting on its own (in memory) and SortDescriptions collection is never modified.
Looking forward for your support on this.