dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.2k stars 9.94k forks source link

QuickGrid: Support sorting with a custom comparer. #45478

Open kuba-si opened 1 year ago

kuba-si commented 1 year ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

We would like to be able to sort with custom comparers, e.g., with a natural string comparer (*).

Which is possible with the current API, but it involves an item provider and custom handling of sortBy / sortAscending. See here. In the Blazor Server example, the pages that use an item provider (i.e.: "Provider" and "Virtualized") have a custom comparer which sorts country names by length rather than alphabetically:

image

This is too convoluted for our needs, though. We populate the grid from lightweight in-memory collections and don't use item providers.

(*) For clarity: we do have a natural string comparer implementation. The problem is that there is no easy way to plug it in.

Describe the solution you'd like

We would like to have a simple API to specify a custom comparer for a single column. And we would like the grid itself to do the sorting. (Perhaps taking advantage of the OrderBy / OrderByDescending overloads which support custom comparers.)

See here for a working prototype for TemplateColumn.

And here for PropertyColumn.

In both cases the custom comparer (that sorts country names by length rather than alphabetically) works in the "In-memory" page:

image

Additional context

No response

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost commented 9 months ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.