Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

MUI X Data Grid shows the wrong page size or resets to page one

ErrorData Grid shows all rows and has no pagination footer

Short answer

Data Grid pagination breaks for four documented reasons: Pro and Premium need the pagination prop, the free grid caps pages at 100 rows, server mode needs paginationMode and a stable rowCount, and and autoPageSize cannot be combined with autoHeight. Check which one matches your setup.

  • Applies to MUI X Data Grid 8, React 19
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find which grid package you import. The Community grid paginates by default; Pro and Premium do not.

    grep -rn "@mui/x-data-grid" src/ package.json
  2. 2Match what you see, then jump to its fix

    1. 1All rows render and there is no footer.Pro or Premium grid without the pagination propFix
    2. 2You set a page size above 100 on the free grid and rows are still capped.Page size above 100 on the free gridFix
    3. 3Changing page does nothing, or the grid resets to page one after each fetch.Server pagination without paginationMode or a stable rowCountFix
    4. 4The grid collapses or shows an odd number of rows.autoPageSize combined with autoHeightFix

What does the error look like?

  • Data Grid shows all rows and has no pagination footer
  • The grid jumps back to page 1 while server data loads

Cause 1 of 4

Pro or Premium grid without the pagination prop

1Check

Pagination is off by default in the Pro and Premium grids.

grep -rn "DataGridPro\|DataGridPremium" src/

2Fix

Add the pagination prop.

<DataGridPro pagination rows={rows} columns={columns} />

3Verify

The footer with rows per page appears.

npm run dev

Confirmed by mui.com

Did this fix it?

Cause 2 of 4

Page size above 100 on the free grid

1Check

The MIT licensed grid is limited to pages of up to 100 rows.

grep -rn "pageSize" src/

2Fix

Use a page size of 100 or less, or move to a Pro or Premium plan for larger pages.

<DataGrid
  rows={rows}
  columns={columns}
  initialState={{ pagination: { paginationModel: { pageSize: 25, page: 0 } } }}
  pageSizeOptions={[10, 25, 50, 100]}
/>

3Verify

The footer shows 25 and the dropdown lists the options.

npm run dev

Confirmed by mui.com

Did this fix it?

Cause 3 of 4

Server pagination without paginationMode or a stable rowCount

1Check

Server mode needs paginationMode='server', a handler on onPaginationModelChange that fetches, and rowCount. If rowCount becomes undefined while loading, the page resets to zero.

grep -rn "rowCount\|paginationMode" src/

2Fix

Control the model, set server mode, and keep rowCount in a memoized value that survives loading.

const [paginationModel, setPaginationModel] = React.useState({ page: 0, pageSize: 25 });
const rowCountRef = React.useRef(rowCount || 0);
const stableRowCount = React.useMemo(() => {
  if (rowCount !== undefined) rowCountRef.current = rowCount;
  return rowCountRef.current;
}, [rowCount]);

<DataGrid
  rows={rows}
  columns={columns}
  rowCount={stableRowCount}
  loading={isLoading}
  paginationMode="server"
  paginationModel={paginationModel}
  onPaginationModelChange={setPaginationModel}
/>

3Verify

Click next page. A request for the new page goes out and the grid stays on it.

npm run dev

Confirmed by mui.com

Did this fix it?

Cause 4 of 4

autoPageSize combined with autoHeight

1Check

autoHeight sizes the grid from pageSize, which conflicts with autoPageSize.

grep -rn "autoPageSize\|autoHeight" src/

2Fix

Remove one of the two props.

<DataGrid rows={rows} columns={columns} autoPageSize />

3Verify

The grid fills its container and pages by what fits.

npm run dev

Confirmed by mui.com

Did this fix it?

How do I stop it coming back?

  • Keep rowCount stable while a page is loading.
  • Check the license tier before relying on page sizes over 100.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.