Nothing Special   »   [go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
PyroGenesis opened this issue Apr 20, 2022 · 0 comments

Comments

@PyroGenesis
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant