-
Notifications
You must be signed in to change notification settings - Fork 66
Description
I have a FastObjectListView with its custom Sort() defined within its VirtualListDataSource. The issue I'm facing is that even if I set the SortOrder of the FOLV to SortOrder.None, it will still attempt to sort in ascending order whenever any addition / deletion occurs.
I saw that insertion and deletion of objects will always attempt to sort and I followed the issue to this block of code:
ObjectListView/ObjectListView/ObjectListView.cs
Lines 8357 to 8383 in 8a10cbd
| // Give the world a chance to fiddle with or completely avoid the sorting process | |
| BeforeSortingEventArgs args = this.BuildBeforeSortingEventArgs(columnToSort, order); | |
| this.OnBeforeSorting(args); | |
| if (args.Canceled) | |
| return; | |
| // Virtual lists don't preserve selection, so we have to do it specifically | |
| // THINK: Do we need to preserve focus too? | |
| IList selection = this.VirtualMode ? this.SelectedObjects : null; | |
| this.SuspendSelectionEvents(); | |
| this.ClearHotItem(); | |
| // Finally, do the work of sorting, unless an event handler has already done the sorting for us | |
| if (!args.Handled) { | |
| // Sanity checks | |
| if (args.ColumnToSort != null && args.SortOrder != SortOrder.None) { | |
| if (this.ShowGroups) | |
| this.BuildGroups(args.ColumnToGroupBy, args.GroupByOrder, args.ColumnToSort, args.SortOrder, | |
| args.SecondaryColumnToSort, args.SecondarySortOrder); | |
| else if (this.CustomSorter != null) | |
| this.CustomSorter(args.ColumnToSort, args.SortOrder); | |
| else | |
| this.ListViewItemSorter = new ColumnComparer(args.ColumnToSort, args.SortOrder, | |
| args.SecondaryColumnToSort, args.SecondarySortOrder); | |
| } | |
| } |
When line 8358 executes, args.SortOrder will be set to SortOrder.Ascending even if the parameter order is set to SortOrder.None due to this block of code:
ObjectListView/ObjectListView/ObjectListView.cs
Lines 4099 to 4103 in 8a10cbd
| if (order == SortOrder.None) { | |
| order = this.Sorting; | |
| if (order == SortOrder.None) | |
| order = SortOrder.Ascending; | |
| } |
Therefore, execution will reach line 8378 and the CustomSorter will be provided a SortOrder of Ascending instead of None.