[DataGrid] Allow programmatic sorting of columns by name or index #2156
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.
Pull Request
📖 Description
The publicly exposed method of programmatically setting a DataGrid's sort order requires the user to have a reference to the
ColumnBase<TGridItem>
which the API does not expose. In order to restore the state of a DataGrid, the sort order needs to be settable.🎫 Issues
#2148 - DataGrid: add access to columns
👩💻 Reviewer Notes
I added 2 logical methods that one would sort by. I did find another
internal
method that could have been used but decided to just add these. I think it would be OK to markSortByColumnAsync
, 'RemoveSortByColumnAsync', andShowColumnOptionsAsync
asinternal
as it is necessary to have aColumnBase<TGridItem>
reference in order to execute those methods, which is something that's not exposed outside of the library.📑 Test Plan
I added new tests for this function based on other existing tests. I used methodology from other tests. I did have to use the
cut.InvokeAsync
method as there is aStateHasChanged()
call within the component.✅ Checklist
General
I did some spellchecking on the DataGrid page.
Component-specific
⏭ Next Steps