[DataGrid] Add OnSortChanged event callback#4573
Merged
Conversation
- Add OnSortChanged event callback - Add handler in example code
|
✅ All tests passed successfully Details on your Workflow / Core Tests page. |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds an OnSortChanged event callback to the FluentDataGrid component, enabling applications to react when the grid's sort order changes. The implementation includes a new DataGridSortEventArgs<TGridItem> class to provide event data containing the sorted column and sort direction.
Changes:
- Added
DataGridSortEventArgs<TGridItem>class to encapsulate sort change event information - Added
OnSortChangedevent callback parameter toFluentDataGrid - Modified
SortByColumnAsyncandRemoveSortByColumnAsyncto invoke the event callback when sorting changes - Updated demo example to demonstrate the new event handler
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Core/Events/DataGridSortEventArgs.cs | New event args class containing Column and SortByAscending properties |
| src/Core/Components/DataGrid/FluentDataGrid.razor.cs | Added OnSortChanged parameter and event invocations in sorting methods |
| examples/Demo/Shared/Pages/DataGrid/Examples/DataGridCustomComparer.razor | Demo implementation of the OnSortChanged handler |
| examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml | Generated XML documentation for the new API |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary - Unit Tests Code CoverageSummary
CoverageMicrosoft.FluentUI.AspNetCore.Components - 61%
|
…icrosoft/fluentui-blazor into users/vnbaaij/datagrid-sort-cb
dvoituron
approved these changes
Feb 25, 2026
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.
Fix #4524