I am trying to use the column headings to sort the grid, but I want the sort to be based on the numeric value of a different value in the data row (not a column that is being displayed). I thought I could do this using a SortComparer, but I am having trouble with the syntax. Can you help?
Hello Ron,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Yeah - I saw that post. It didn't really help me. I found a different solution. I am not sure this is the best/cleanest solution, but this seems to be working for me:
1. on the "sorting" event, set a converter for the field to return the data value from the second column name
2, on the "sorted" event, reset the converter to null
Here is the code:
private void dgData_Sorting(object sender, Infragistics.Windows.DataPresenter.Events.SortingEventArgs e) { if (e.Field.Name == "Column1") { e.Field.Converter = new PriorityConverter(); } }
private void dgData_Sorted(object sender, Infragistics.Windows.DataPresenter.Events.SortedEventArgs e) { if (e.Field.Name == "Column1") { e.Field.Converter = null; } } ... public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { DataRecord dr = (DataRecord)parameter; return dr.Cells["Column2"].Value; }
Thank you for your post. I have been looking into it and I can suggest you see this forum thread:
http://ko.infragistics.com/community/forums/p/75182/379935.aspx
where a similar issue is already discussed. The sample there shows how to sort the GroupBy records the way you want, but the same SortComparer can be used for a normal sorting as well. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.