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
|
Hi There, Lets say I have 3 columns on a DataTable: columnID, columnVal1, columnVa2. On a function
then it will not sort it as we hoped. If I set the SortComparer for all the columns in one function:
and Set SortDirection on another function:
and called it in order as:
Then everything is ok. It seems after set SortDirection for one column you cannot set SortComparer for other columns later. Is this a proper behaviour? Thanks, Gordon |
|
|
Hello Gordon The sort comparer will only have effect if the sort direction of that column is not None. When performing a custom sort operation, make sure both the direction and the comparer are being set. The order of setting them does not matter. Also note that the DataGrid currently only supports sorting 1 column at a time. Sorting by another column will undo sorting on the previous column. -Jason Fauchelle |
|
|
Hi Jason, We set custom sort for all the columns that needs to so that when user click on the column header it will sort properly. At same time we set one of the columns' SortDirection to not None. Here is example
This will not sort first column as decending. But if I don this:
Then it will sort the first column for me. Thanks, Gordon |
|
|
Thanks Gordon, I understand the issue now. The result of the sorting is based on the last column that had its sorting state changed. I would not say this is the expected behavior, but it will be a bit tricky to adjust this code. The best solution would be for you to use the second code snippet you posted. So always change the sorting on the desired column last. I've made a note to fix this later. -Jason Fauchelle |
|