This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
In some cases I need to do custom sorting of columns in the DataGrid. By this I mean exclude a fixed number of rows from the top or bottom from the sort (e.g., to keep totals row at the bottom), or to sort grouped rows (keeping groups together). Anyway I had implemented this in the Microsoft DataGrid by implementing a custom ListCollectionView that did the custom sorting I required, setting the ItemsSource of the DataGrid to my custom ListCollectionView, and overriding DataGrid.OnSorting(DataGridSortingEventArgs e) to apply my custom sort. Is there a way I can implement such a custom sort with the Mindscape DataGrid? Supplying a sort comparer is not sufficient. My aim it to transition completely to the Mindscape DataGrid. I am using a recent build of version 6. |
|
|
I forgot to mention another sort requirement I have is that the sort be stable--meaning that the relative ordering of rows with equal keys is maintained. This allows users to simulate the effect of having a multi-column sort key simply by clicking the column headers in reverse order of priority (I find that once this feature is explained to users they really like it). Anyway, quicksort is not inherently stable. As proof of concept I modified the DataGrid and DataGridItemsSource to give me the functionality I need: In DataGrid added the property
and modified UpdateSort as follows:
In DataGridItemsSource I added two properties:
And inserted a few lines of code in Sort:
Then after constructing the DataGrid I simply assign my the CustomSort property of the DataGrid to my custom sort rounting that implements all the features I need. This is not the most robust and general implementation of this custom sorting concept, but it works great for me. Peter |
|
|
Hello Peter There currently isn't a way to provide a custom sorting routine other than setting the SortComparer of one or more columns. I'll look at adding the custom sorting hook in for you early next week. Jason Fauchelle |
|
|
Hello Peter The next nightly build will include the DataGrid.CustomSort property which will function just like your proof of concept. Jason Fauchelle |
|
|
Hi Jason, Thanks! Peter |
|