-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[data grid] rowCount
with paginationMode='client'
and infinite loading with onRowsScrollEnd
#14735
Comments
@yoshegg If you have a known row count, it is recommended to use lazy-loading rather than infinite loading which gives some added benefits like prerendering the viewport so that the user can go to any page down the tree and fetch that one instead of going through pages (or chunks) one by one. I tried to update your example with lazy loading and it doesn't show the error anymore: https://codesandbox.io/p/sandbox/keen-lucy-vvlnh3 Let me know if it makes sense. Sidenote: I moved some static variables like |
@MBilalShafi thank you. We want to use infinite loading because it works easily with TanStack Query's
Thanks for pointing out the change to columns and rows. For the sake of the MWE, I did not bother to memoize. |
rowCount
with paginationMode='client'
and infinite loading with onRowsScrollEnd
By logging the error, the intention is to be clear that infinite loading is supposed to be a client-side feature. That means that even if the data is being loaded from a server, the user is handling it and reacting to changes like filtering and sorting outside the data grid scope. (Basically resetting the However, that changes with the new lazy-loading feature with the data source which combines both lazy-loading and infinite loading both of which essentially corresponds to the presence or absence of the Coming to your question, I'd say to ignore the error for now if the use-case works for you (it's not shown in production anyway) and aim to switch to the data source variant of infinite loading since the current infinite loading feature is most probably going to be deprecated and removed ultimately. CC @arminmeh Feel free to add something if you want. By the way, as far as I understand, the |
The new feature will also not allow showing total number of rows in combination with infinite loading. It will automatically fill the grid with skeleton rows to match the count. Regarding the error itself, I see that we have an inconsistency there. |
I did a quick search and it looks like |
That's what we are doing right now. But we remove it? It works perfectly fine.
Yes, and that's what I'm using. But: If I don't provide the
In this case I would just recreate the exact footer that is shown right now just to get rid of the error being logged. |
I did open a new issue to change the log type from error to a warning: #14887 |
Yes, it seems like something that should reduce some friction, I'd also be in favor of making it easier to customize the |
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 theonRowsScrollEnd
prop. My backend provides me the total amount of data immediately on the first call. I set therowCount
prop to be this number. Unfortunately, I get an error in the DevTools console: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`
Search keywords: DataGrid paginationMode rowCount onRowsScrollEnd infinite-loading
Order ID: 95669
The text was updated successfully, but these errors were encountered: