I have a grid that uses XamComboEditor, and I would like to write a custom sort. I have the sortcomparer assigned on the field, but the data coming to the compare appears to be the value rather than the displayed value. How do I sort on the displayed value?
The XamDataGrid will use the ValuePath property of the XamComboEditor to sort the items. You may try to set this property to be the same as the DisplayMemberPath.
Let me know if this will work for you.
My XamDataGrid is binded to a DataSet. The column in the DataSet contains a GUID. I'm setting the Field in the XamDataGrid to a XamComboEditor so that I can display the associated strings.
So, the ValuePath is set to a GUID, which is what needs to be in the column in the DataSet, and the DisplayMemberPath is set to a String associated with that GUID. I need to be able to sort by the DisplayMemberPath, otherwise, the strings will not sort properly. Is there a way I can do this?
I have a custom comparer set for the field. It is provided with the actual GUID value of the field. I am wondering how to provide it with the value displayed in the Combo Box instead.
I've tried to duplicate the same scenario in a sample project but the sorting seems to work fine on my side. The Field is bound to an Integer property but the values are sorted by the DisplayMemberPath values of the combo. Let me know if this is closer to your scenario and if you can resolve the issue with this.
This works as expected, however, as I stated, I would like to implement my own custom sort. I have added some different data to the grid. I want to implement a natural order sort, so that it sorts like:
T 1, T 2, T 10, T 20, T 101
However, using the default sort, it sorts as:
T 1, T 10, T 101, T 2, T 20
Since the field has a "SortComparer" setting, I have set this to use the class MyColumnComparer (which implements IComparer). I have not added any logic to the comparer, so I don't expect it to work. I had this working in a WindowsForms UltraGrid, and plan to add in the code later.
However, the problem is that the x and y provided to the compare function are the int values rather than the displayed strings.
How do I implement a custom sort on the displayed strings?
Sorry, here is the modified project.
kelmore said: This works as expected, however, as I stated, I would like to implement my own custom sort. I have added some different data to the grid. I want to implement a natural order sort, so that it sorts like: T 1, T 2, T 10, T 20, T 101 However, using the default sort, it sorts as: T 1, T 10, T 101, T 2, T 20 Since the field has a "SortComparer" setting, I have set this to use the class MyColumnComparer (which implements IComparer). I have not added any logic to the comparer, so I don't expect it to work. I had this working in a WindowsForms UltraGrid, and plan to add in the code later. However, the problem is that the x and y provided to the compare function are the int values rather than the displayed strings. How do I implement a custom sort on the displayed strings?
Hello,
I am into similar situation where I would need to skip blank rows being includeed in sorting. We have 40 rows in grid out of which only 3 rows are populated by the user.
Is there any setting available to perform the same or what should I customize to make that happen.
Thanks,
Muthu