Repository navigation
feat: sort groups by a summary value such as the group's sum or count (#405) - #518
Open
michaelstonis wants to merge 2 commits into
Open
michaelstonis wants to merge 2 commits into
michaelstonis wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #405.
Changes
Groups can now be ordered by an aggregate over each group's rows instead of by key.
GroupDescription.SortBySummary(SummaryColumnDescription?, default null = key order). OnlyPropertyName,SummaryTypeand, forCustom,CustomAggregateare used;Countcounts the group's rows and ignores the property. The existingSummaryColumnDescriptionis reused (the issue's open question); no new type.ViewBuilder:GroupSpeccaptures aGroupSortSummarySpec(anItemReaderfor the property plus a private copy of the description, so worker builds never read live objects). In the grouping loop, onePropertyAggregateper bucket is fed while rows are assigned to buckets (same accumulators as visible summaries, so null handling and numeric conversion match; no extra pass, one extra read per row per level that uses it). Buckets then sort by aggregate (KumikoComparer: numbers numerically, dates chronologically), then by key, then display text, then first appearance. The direction isGroupSortDirectionand applies to the key tie-break too. Same code path for synchronous and background builds.KumikoSource.ItemPropertyImpactreturnsPropertyImpact.Rowsfor a change to a property a level sorts by (not forCount, which does not read it), so the groups reorder; expanded state is keyed byGroupKeyPathand survives.KumikoGroupLayoutStategainsSortSummaryPropertyNameandSortSummaryType(nullable, additive;CurrentVersionstays 1).CustomAggregateis not saved. Applying a layout that saved no summary clears a non-customSortBySummaryand keeps a code-set custom one. This edit is two properties at the end of the class, to keep it small for the Layout state: save and restore expanded groups, selection, scroll position and summary rows #354 branch.GroupSortDirection, which now flips the summary order as well (documented in the XML docs and README).Public API added (in
PublicAPI.Unshipped.txt):GroupDescription.SortBySummary(get, set),KumikoGroupLayoutState.SortSummaryPropertyName(get, set),KumikoGroupLayoutState.SortSummaryType(get, set).Acceptance criteria
tests/KumikoUI.Core.Tests/KumikoSourceGroupingTests.cs: Sum, Average, Count, Min, Max and Custom in both directions; ties by key; Count ignores the property; filter applies; nested levels independent; item change reorders; layout state round trip (plus no-summary and apply-without-summary cases). The synchronous-versus-background comparison is inBackgroundRebuildTests.csnext to the other background-equals-synchronous tests (it needs that file's worker harness).GroupDescriptionsis already settable on both hosts, so there is no host code. The nestedSummaryColumnDescriptionelement (GroupDescription.SortBySummaryproperty element) was verified to compile in the Uno sample XAML. The MAUI sample project does not restore on this machine (NU1605 package conflict between SkiaSharp.Views.Maui and Microsoft.Maui.Controls, unrelated to this change), so MAUI XAML parsing of the nested element was not compiled here; the MAUI library builds.PublicAPI.Unshipped.txtupdated.eng/update-public-api.sh Coreemptied the file without regenerating it in this environment, so the six new lines were added by hand (the file was restored first); the build reports no RS0016.Verification
dotnet test tests/KumikoUI.Core.Tests: Passed 4383, Failed 0, Skipped 5 (the skips are pre-existing).dotnet build src/KumikoUI.Core,src/KumikoUI.SkiaSharp: 0 warnings, 0 errors.dotnet build src/KumikoUI.Maui -f net10.0-maccatalyst,dotnet build src/KumikoUI.Uno -f net10.0-desktop: 0 errors (no new warnings; the existing Uno0001 notice remains).dotnet build samples/SampleApp.Uno -f net10.0-desktop: 0 errors, with and without a temporary nestedSortBySummaryXAML element on the page.dotnet build samples/SampleApp.Maui -f net10.0-maccatalyst: fails at restore (NU1605), not caused by this change.KumikoDataGrid.GroupDescriptions, so both documentation snippet projects build with 0 errors (a barecore:element is wrapped as a column).