We need to send the grid sorting configuration to the backend system. Is the below approach using the UniqueName property going to be reliable? If not can you please advise on the most reliable means to get the information necessary to extract the bound property name.
5 Answers, 1 is accepted
Your approach seems fine if you're using ColumnSortDescriptor.
If you prefer, I would suggest the following approach in order to achieve the desired result, provided you use SortDescriptors:
I would also suggest having a look at the Programmatic Sorting section of our documentation if you haven't done so already.
Please let me know if this works for you.
Well, guess I'm back to using ".Column.UniqueName".
Unable to cast object of type 'Telerik.Windows.Controls.GridView.ColumnSortDescriptor' to type 'Telerik.Windows.Data.SortDescriptor'.
Dilyan, I really feel uncomfortable to use the UniqueName approach as it feels there's very little guarantee for it to always be the same as the member name. Any advice regarding this would be greatly appreciated
You are given this exception for one of two reasons:
1) You're sorting RadGridView through the UI, so a ColumnSortDescriptor is added to the SortDescriptors collection.
2) You've defined a ColumnSortDescriptor in your SortDescriptors collection either programmatically or through XAML.
I want to note that If you do not explicitly set the UniqueName for your column, it will be the same as the property to which you're binding the DataMemberBinding. So I believe there is nothing to worry about and you should have no problems using the ColumnSortDescriptor and its Column.UniqueName.
Yes, we are doing no.1 allowing the user to determine the sort order on the server data before running their search/page requests. We're currently using Column.UniqueName and all is working great, I'm just a bit concerned that at some point the value stored in UniqueName might change as no one can be held to guaranteeing it being the member name, the only guarantee is that it should be a unique name. As for now, you seem pretty confident that it wouldn't be used to store any other unique data so that's good enough for me.
Thanks for for your time.