Skip to content

Provide custom comparer support for in-memory QuickGrid sorting#67035

Open
VigneshwaranGovindharajan wants to merge 8 commits into
dotnet:mainfrom
VigneshwaranGovindharajan:VigneshwaranGovindharajan-feature-45478-custom-comparer
Open

Provide custom comparer support for in-memory QuickGrid sorting#67035
VigneshwaranGovindharajan wants to merge 8 commits into
dotnet:mainfrom
VigneshwaranGovindharajan:VigneshwaranGovindharajan-feature-45478-custom-comparer

Conversation

@VigneshwaranGovindharajan

Copy link
Copy Markdown

Provide custom comparer support for in-memory QuickGrid sorting

Description

Adds support for custom comparisons in QuickGrid sorting by accepting an IComparer on GridSort and exposing comparer usage on PropertyColumn. This enables consumers to supply custom ordering (for example, sort strings by length, by vowel count, or integers by absolute value) when the data is materialized in memory.

Important: custom comparers are supported only when sorting is performed in-memory (LINQ-to-Objects). They cannot be translated to SQL/EF Core; trying to use comparers with remote IQueryable providers will not work and may cause runtime translation failures. Documentation and XML remarks call this out.

Changes:

  • Added comparer overloads on GridSort:

  • ByAscending(Expression<Func<T, U>> keySelector, IComparer comparer)

  • ByDescending(Expression<Func<T, U>> keySelector, IComparer comparer)

  • ThenAscending(Expression<Func<T, U>> keySelector, IComparer comparer)

  • ThenDescending(Expression<Func<T, U>> keySelector, IComparer comparer)

  • Each overload includes XML docs noting the in-memory-only restriction.

  • PropertyColumn<T, TProp>:

  • New [Parameter] public IComparer? Comparer { get; set; }

  • Column builds the column's sort specification using the comparer when provided.

  • Tracks comparer changes so the column updates SortBy when the comparer parameter changes.

  • Wiring:

  • GridItemsProviderRequest.ApplySorting(IQueryable) already calls SortByColumn?.SortBy?.Apply(...). The GridSort comparer overloads pass the comparer through to LINQ OrderBy/ThenBy overloads when the source is in-memory.

Fixes #45478

@VigneshwaranGovindharajan VigneshwaranGovindharajan requested a review from a team as a code owner June 5, 2026 10:44
@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Jun 5, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jun 5, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @VigneshwaranGovindharajan. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@VigneshwaranGovindharajan

Copy link
Copy Markdown
Author

#67035

@VigneshwaranGovindharajan

Copy link
Copy Markdown
Author

@dotnet-policy-service agree company="Syncfusion, Inc."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QuickGrid: Support sorting with a custom comparer.

1 participant