Skip to content

FastObjectListView with custom sorter does not abide by SortOrder.None #14

Description

@PyroGenesis

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:

// 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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions