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
Update MudDataGrid to work with MudPagination #8821
base: dev
Are you sure you want to change the base?
Conversation
MudDataGrid only had a Page (last, next, first,...) based NavigateTo method. Added a int based NavigateTo. Inspired by the MudTableBase version.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #8821 +/- ##
==========================================
+ Coverage 89.82% 90.14% +0.31%
==========================================
Files 412 421 +9
Lines 11878 12216 +338
Branches 2364 2409 +45
==========================================
+ Hits 10670 11012 +342
+ Misses 681 663 -18
- Partials 527 541 +14 ☔ View full report in Codecov by Sentry. |
Hi, thanks for PR. It's required to add a bUnit test for this feature. |
/// <param name="pageIndex">Index of the page to navigate to.</param> | ||
public void NavigateTo(int pageIndex) | ||
{ | ||
CurrentPage = Math.Min(Math.Max(0, pageIndex), numPages - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@henon do you think we should allow this in v7 PRs to write directly to parameter in components that didn't migrate to ParamterState
? Or we should kindly ask to migrate whole property to ParameterState
+ add new feature, but this would be quite some work as there are 22 references to CurrentPage
property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we must request to use the state framework for new parameters that are manipulated or new API that will manipulate parameters in order to avoid the necessity for future breaking changes.
Because in this case with using the state framework it would have to be NavigateToAsync
because you have to call await _currentPageState.SetValueAsync(...)
.
Added tests for int based NavigateTo method
@ScarletKuro Added tests to the existing DataGridPaginationTest method. I did not add a MudPagination component to the DataGridPaginationTest test component but I thought that was fine, please let me know if not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Thanks for the addition, @digitaldirk!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@digitaldirk can you please read CONTRIBUTING.md so you know what we are talking about? If you then have questions we'll answer and help.
Please register parameter CurrentPage
using our new state framework and avoid writing to the parameter by modifying the _currentPageState
object instead. In the unit test, it depends on whether or not CurrentPage
is two-way bound. If so it can remain as it is. If not you'll have to use GetState<int>(nameof(CurrentPage))
to get the value of CurrentPage
.
Description
MudDataGrid only had a Page (last, next, first,...) based NavigateTo method. Added a int based NavigateTo method so the MudPagination component can be used with the MudDataGrid component. Inspired by the MudTableBase.cs version. Resolves #8819
How Has This Been Tested?
Visually tested with docs project, and added unit tests.
Used this code:
Type of Changes
Checklist
dev
).