Skip to content

[data grid] rowCount with paginationMode='client' and infinite loading with onRowsScrollEnd #14735

Open
@yoshegg

Description

@yoshegg

The problem in depth

I want to have infinite loading with DataGridPremium as described here: https://mui.com/x/react-data-grid/row-updates/#infinite-loading

I'm using TanStack Query with useInfiniteQuery which means I can trigger the loading of additional rows with a separate function (fetchNextPage), which I hand over to the onRowsScrollEnd prop. My backend provides me the total amount of data immediately on the first call. I set the rowCount prop to be this number. Unfortunately, I get an error in the DevTools console:

MUI X: Usage of the `rowCount` prop with client side pagination (`paginationMode="client"`) has no effect. 
`rowCount` is only meant to be used with `paginationMode="server"`. 

Still, the DataGrid behaves as expected: As long as I haven't loaded all the rows, it shows Total Rows: 15 of 22 in the footer. When I scroll and therefore trigger fetchNextpage, it shows Total Rows: 22. Perfect!

So is there actually a need to log this error at all?

I have prepared a MWE here: https://codesandbox.io/p/sandbox/relaxed-monad-3h5wgm

Your environment

`npx @mui/envinfo`
  System:
    OS: macOS 14.6.1
  Binaries:
    Node: 22.8.0 - ~/.nvm/versions/node/v22.8.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v22.8.0/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: 129.0.6668.70
    Edge: Not Found
    Safari: 17.6
  npmPackages:
    @emotion/react: 11.13.3 => 11.13.3 
    @emotion/styled: 11.13.0 => 11.13.0 
    @mui/core-downloads-tracker:  6.1.1 
    @mui/icons-material: 6.1.1 => 6.1.1 
    @mui/material: 6.1.1 => 6.1.1 
    @mui/private-theming:  6.1.1 
    @mui/styled-engine:  6.1.1 
    @mui/system:  6.1.1 
    @mui/types:  7.2.17 
    @mui/utils:  6.1.1 
    @mui/x-data-grid:  7.18.0 
    @mui/x-data-grid-premium: 7.18.0 => 7.18.0 
    @mui/x-data-grid-pro:  7.18.0 
    @mui/x-internals:  7.18.0 
    @mui/x-license:  7.18.0 
    @types/react:  18.3.9 
    react: 18.3.1 => 18.3.1 
    react-dom: 18.3.1 => 18.3.1 
    typescript:  5.6.2 

Search keywords: DataGrid paginationMode rowCount onRowsScrollEnd infinite-loading
Order ID: 95669

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: data gridThis is the name of the generic UI component, not the React module!docsImprovements or additions to the documentationfeature: PaginationRelated to the data grid Pagination featurefeature: Server integrationBetter integration with backends, e.g. data sourcesupport: commercialSupport request from paid userssupport: premium standardSupport request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions