Skip to content

Add public Sort, Group and Ungroup methods to TableViewColumn - #471

Open
AsafMah wants to merge 2 commits into
w-ahmad:mainfrom
AsafMah:feature/column-group-sort-api
Open

AsafMah wants to merge 2 commits into
w-ahmad:mainfrom
AsafMah:feature/column-group-sort-api

Conversation

@AsafMah

@AsafMah AsafMah commented Oct 28, 2026 •

Copy link
Copy Markdown

Description

Adds public Sort, Group, Ungroup and IsGrouped to TableViewColumn: the code-side equivalent of the column header's Sort/Group/Ungroup commands.

Today an app can group or sort from code only by adding a plain GroupDescription/SortDescription. Those aren't tied to a column (ColumnGroupDescription and ColumnSortDescription are internal), so the header shows no sort indicator for them and its Ungroup command doesn't apply. Starting a table grouped by a column, but still letting the user ungroup it from the header, isn't possible. I hit this in an app that groups devices by class by default.

The logic moved from TableViewColumnHeader (private Group, DoSort, ClearSortingWithEvent) to the column unchanged, and the header now calls the column. UI and code share one path. Behavior notes:

  • Group() returns false when grouping isn't allowed (CanGroup/CanGroupColumns), the column is already grouped, or a Grouping handler sets Handled.
  • Sort() returns false when sorting isn't allowed or a Sorting handler handles it.
  • Ungroup() doesn't require CanGroup, so grouping can always be removed. The header still gates its command on CanGroup as before.

Related Issue

None opened; happy to open one or move this to a discussion if you'd prefer.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 📝 Documentation update
  • ♻️ Refactor
  • 🧪 Test
  • 🔧 Chore / maintenance

Checklist

  • This PR is not from my main branch
  • Tested with WinUI target (builds and runs in an app that groups by a column from code; ungrouping from the header not yet exercised by hand)
  • Tested with Uno Platform target (not tested; Group/Ungroup/IsGrouped are inside #if WINDOWS like the rest of grouping)
  • Unit / integration tests added or updated (TableViewColumnSortingAndGroupingTests, 13 tests, passing locally)
  • Documentation updated to reflect changes (grouping.md, sorting.md)
  • Code follows the project's coding conventions

Additional Notes

Update: I got the WinUI test host running locally (building with -p:Platform=x64 and running the exe; the host from dotnet test --arch x64 exits at startup on my Windows Insider build). The 13 new tests pass, and the full suite passes except SelectingARowWithWideDetails_KeepsTheSelectionVisualsOnTheCells, which fails the same way on unmodified main here.

🤖 Generated with Claude Code

AsafMah and others added 2 commits October 28, 2026 13:58
Grouping or sorting by a column from code needed the internal ColumnGroupDescription
and ColumnSortDescription, so an app couldn't start grouped by a column and still
let the user ungroup it from the column's header. The header's commands now call
these methods, so code and UI share one path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant