Following on from http://forums.infragistics.com/forums/p/3550/18864.aspx#19703
If I change the cell value of a row that is being used in a grouped sort, and manually call RefreshSortPosition on the row, I am finding that the row position will sometimes change (depending on other sorts on the grid), but it does not move to the correct group.
I can verify it using this code:
' Update row with new data grdRow.RefreshSortPosition() ' Check to see if we should have moved group If grdRow.ParentRow IsNot Nothing Then If grdRow.ParentRow.IsGroupByRow Then ' Get the correct value from the row, for the relevant column If CStr(grdRow.Cells(CType(grdRow.ParentRow, UltraGridGroupByRow).Column).Value) <> Cstr(CType(grdRow.ParentRow, UltraGridGroupByRow).Value) Then Debug.WriteLine("Row hasn't been moved to the correct group!!!") End If End If End If
Can anyone think of a reason this would happen?
Furthermore, this does not happen on all columns. I am trying to see what is different between the columns with the problem, and those without... :-/
Ah ha!
Ok, the columns with the problem have a custom SortComparer, because they contain Integer values that are converted to text using a valuelist, and need to be sorted by the underlying value rather than the text. Why would this prevent the rows being moved to the new group when the value changes? Do I need to make use of the GroupByComparer?
Hello,
I created a sample based on your description, please check the attached sample and let me know if this is what you are trying to do, else please modify the sample to reproduce the issue
Please send me your SortComparer class as well.
Thank you,
Thanks for getting back to me. I have attached a different sample which should demonstrate the issue quite well.
Hi,
Just want to follow up on something...
I ran your sample. If I expand any group and select the first row in that group and click the button, I get the results you describe, the row does not move to the correct group.
But it works fine for any row other than the first row. Is that the result you are getting?
I downloaded the source for the current release (10.2.2117) and discovered that there appeared to be a fix for this issue in that release.
However, in perusing the source code for the area responsible for moving the row into the right group, I discovered a way to resolve the issue permanently without installing the latest release. The primary issue is that the grid uses the custom SortComparer to determine what to do with the groups, but there are limitations with this approach when there is a single row in the group since you need at least two rows for SortComparer to work correctly.
Fortunately, I also discovered that if the column contains a GroupByEvaluator, this will take precedence over the SortComparer and will place the rows in the correct groups every time with a relatively minimal amount of code. So, the solution to the problem is that if you are using a custom SortComparer on a column that is also grouped, add a GroupByEvaluator to the column and the groups will work correctly when the row data is changed.