Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Allow programmatic sorting of columns by name or index #2156

Merged

Conversation

ksbecker
Copy link
Contributor

@ksbecker ksbecker commented Jun 5, 2024

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 mark SortByColumnAsync, 'RemoveSortByColumnAsync', and ShowColumnOptionsAsync as internal as it is necessary to have a ColumnBase<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 a StateHasChanged() call within the component.

✅ Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

I did some spellchecking on the DataGrid page.

Component-specific

  • I have modified an existing component
  • I have validated the Unit Tests for an existing component

⏭ Next Steps

@ksbecker
Copy link
Contributor Author

ksbecker commented Jun 5, 2024

@microsoft-github-policy-service agree

@ksbecker ksbecker requested a review from dvoituron June 5, 2024 20:09
@vnbaaij vnbaaij changed the title Add options to allow programmatic sorting of columns by name or index {DataGrid] Allow programmatic sorting of columns by name or index Jun 6, 2024
@vnbaaij vnbaaij changed the title {DataGrid] Allow programmatic sorting of columns by name or index [DataGrid] Allow programmatic sorting of columns by name or index Jun 6, 2024
@vnbaaij vnbaaij merged commit 3d1eb51 into microsoft:dev Jun 6, 2024
2 checks passed
vnbaaij added a commit that referenced this pull request Jun 12, 2024
)

* Add options to allow programmatic sorting of columns by column name or column index

* Added unit tests

* Use method overloads instead of explicit method names.

---------

Co-authored-by: Kevin Becker <[email protected]>
Co-authored-by: Vincent Baaij <[email protected]>
@ksbecker ksbecker deleted the 2148-Feature-AddSortMethodsForDataGrid branch August 20, 2024 18:46
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.

3 participants