Replied 7 August 2017, 4:42 pm EST
But after I did a sort on CustomIndex, if the user click on Age again does the grid will sort Ascending or Descending ? Will the user be able to switch from Ascending/Descending, let's say if after a sort I re-sort by CustomIndex ?
Good point. In order to accomplish that, you will need to add the ColumnIndex to the sort collection instead of replacing it. For example, in your sample, you would sort by ColumnIndex and Age (in that order) instead of just by ColumnIndex.
But maybe you need more special handling. If the user clicks Age again (to change from ascending to descending), do you want to preserve the custom changes or do you want to sort by Age entirely? The default approach would be to remove the special changes and sort by Age.
Other approach I can think of is to change all the SortMemberPath (not putting the same than the column itself). For example, for the Age column you might put CalculatedAge as SortMemberPath. Then, in the dataview you might have those columns with your custom logic..
I'am saying that because in VB6, I was using C1FlexGrid and after a Sort I was able to move rows (without having to create a CustomIndex column), and I just want the same capabilities in Silverlight.
Yes, I understand. There are two things here: our C1DataGrid follows the built-in DataGrid object model and philosophy. In particular, we delegate the full view state to the CollectionVIew and react to its changes. If we allow to make changes to the control which conflicts with the state in the CollectionView there is no way we can keep the information consistent. (i.e. we receive a CollectionChanged event with type Add in the index 10, what should we do? C1DataGrid doesn't know how to sort, it's made by the CollectionView. How do you do if the data comes from RIA services instead?).
The correct way in Silverlight to do this, is to make your own "ModelView", in this case, implement your own ICollectionView. But that's a fairly complicated task, that's why I am suggesting these workarounds adding calculated columns and using the built-in sorting.
One of the things we don't support in the C1DataGrid is an "unbound mode". Maybe the Silverlight C1FlexGrid can help you in this scenario in a better way as it does support unbound mode and has a similiar API to the one in WinForms, which allows you to do "less-silverlighty" things...
Hope this helps!