Skip to content

MudDataGrid, MudTable: Don't stay on empty page after ServerData load - #13949

Merged
danielchalmers merged 1 commit into
MudBlazor:devfrom
Denis6902:fix/server-data-page-reset-at-boundary
Oct 12, 2026
Merged

danielchalmers merged 1 commit into
MudBlazor:devfrom
Denis6902:fix/server-data-page-reset-at-boundary

Conversation

@Denis6902

Copy link
Copy Markdown
Contributor

Fixes #13948

What: With ServerData, both MudDataGrid and MudTable reset CurrentPage to 0 after a load when the current page lies beyond the returned TotalItems. The check used >, so a result whose total is exactly equal to the offset of the current page (for example 30 items while on page 4 with 10 rows per page) was treated as still valid, and the grid stayed on an empty page with the pager showing 31-30 of 30. The comparison is now >= in MudDataGrid.InvokeServerLoadFunc and MudTable.InvokeServerLoadFunc.

Why it is safe: when the current page is already 0 the condition can only trigger CurrentPage = 0 / SetCurrentPage(0), and both are no-ops for an unchanged value, so an empty result on the first page does not cause an extra load.

Tests:

  • DataGridTests.ServerDataResetsToFirstPageWhenCurrentPageOverflows (regression cover for the existing reset path, there was none for the grid)
  • DataGridTests.ServerDataResetsToFirstPageWhenTotalItemsEqualsPageOffset (the boundary; fails without the fix: Expected dataGrid.CurrentPage to be 0, but found 2)
  • TableTests.ServerDataResetsToFirstPageWhenTotalItemsEqualsPageOffset (the boundary; fails without the fix: Expected table.CurrentPage to be 0, but found 2)
  • New test component DataGridServerDataPageResetTest.razor, modelled on the existing TableCurrentPageServerDataReapplyTest.razor

Verified locally with the filtered run --filter "FullyQualifiedName~Components.DataGridTests|FullyQualifiedName~Components.TableTests".

No public API change, no breaking behavior.

AI assistance: the fix, the tests and this description were drafted with an AI coding assistant (Claude) and reviewed and run by me.

Before/After:

Before: on page 4 with 10 rows per page, a filter that leaves exactly 30 items shows an empty grid with the pager 31-30 of 30.
After: the grid moves to page 1 and shows 1-10 of 30.

Before
obrazek

After
obrazek

Checklist:

  • I've read the contribution guidelines
  • My code follows the style of this project
  • I've added or updated relevant unit tests

…t with ServerData (MudBlazor#13948)

With ServerData the page was reset to 0 only when CurrentPage * RowsPerPage was greater than TotalItems. When the total was exactly equal to the offset of the current page, the grid or table stayed on an empty page (pager showed e.g. 31-30 of 30). The comparison is now >= in MudDataGrid.InvokeServerLoadFunc and MudTable.InvokeServerLoadFunc; both setters are no-ops for an unchanged page, so an empty first page does not trigger an extra load.

Tests: DataGridTests.ServerDataResetsToFirstPageWhenCurrentPageOverflows, DataGridTests.ServerDataResetsToFirstPageWhenTotalItemsEqualsPageOffset, TableTests.ServerDataResetsToFirstPageWhenTotalItemsEqualsPageOffset and the test component DataGridServerDataPageResetTest.

Fixes MudBlazor#13948
@mudbot mudbot Bot changed the title DataGrid, Table: Reset the page when TotalItems equals the page offset with ServerData (#13948) MudDataGrid, MudTable: Reset the page when TotalItems equals the page offset with ServerData Oct 6, 2026
@mudbot mudbot Bot added bug Unexpected behavior or functionality not working as intended needs: visuals Missing screenshots or video for UI bugs or design changes labels Oct 6, 2026
@mudbot

mudbot Bot commented Oct 6, 2026

Copy link
Copy Markdown
  • Could you post a before and after video showing the fix from your own run?

I'm an AI assistant — If I missed something or made a mistake, please let me know in a reply!

@Denis6902

This comment was marked as low quality.

@mudbot mudbot Bot removed the needs: visuals Missing screenshots or video for UI bugs or design changes label Oct 7, 2026
@danielchalmers

Copy link
Copy Markdown
Member

Please post before and after videos that were recorded yourself from your own local run.

@danielchalmers danielchalmers added the needs: visuals Missing screenshots or video for UI bugs or design changes label Oct 7, 2026
@Denis6902

Copy link
Copy Markdown
Contributor Author

Here are before and after videos recorded from my own local run of MudBlazor.UnitTests.Viewer, using a local demo page with the snippet from #13948 (the page is not part of the PR). Steps: go to page 4 in both grids, then click Filter to 30 items.

Before (this branch with the fix reverted): both MudDataGrid and MudTable stay on page 4 with no rows, and the pager reads 31-30 of 30.

2026-10-07.17-27-58.mp4

After (this branch): both grids move to page 1 and the pager reads 1-10 of 30.

2026-10-07.17-29-35.mp4

@danielchalmers danielchalmers removed the needs: visuals Missing screenshots or video for UI bugs or design changes label Oct 7, 2026
@danielchalmers
danielchalmers merged commit d866792 into MudBlazor:dev Oct 12, 2026
12 checks passed
@danielchalmers

Copy link
Copy Markdown
Member

Thanks!

This was referenced Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataGrid/Table with ServerData: page is not reset when TotalItems equals the current page offset (off-by-one in CurrentPage * RowsPerPage > TotalItems)

2 participants