-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[DataGridPro] Ignore missing rowCount response when new children are fetched with the data source
#17711
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
Merged
arminmeh
merged 2 commits into
mui:master
from
arminmeh:ignore-row-count-while-loading-children
Jun 19, 2025
Merged
[DataGridPro] Ignore missing rowCount response when new children are fetched with the data source
#17711
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
IMO, there are a couple of reasons why updating the
rowCountduring child data fetches would make sense:getRows) is utilized for both root and nested data. Its return type includesrowCount, so from a TypeScript perspective, it should accept and processrowCountregardless of the data’s nesting level. Changing this without any clear indication may cause slightly unpleasant DX.rowCountmight change in the background. Allowing updates to the rootrowCountalongside nested data fetches can eliminate the need for an additional API call solely to retrieve the updated row count. It may particularly help specific cases where API calls are expensive.How about reverting to the v7 behavior—where
rowCountupdates are ignored if passed asundefined(except during the initialgetRowscall)? Do you foresee some potential issues with this approach?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.
How about giving users an option to control this behavior—perhaps something like an
ignoreRowCountOnChildFetchparameter? It doesn't have to be that exact name, but something along those lines to provide flexibility.Uh oh!
There was an error while loading. Please reload this page.
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.
Agree with the point about the consistency.
Taking all of this into the consideration, I think that the right behavior then would be to consider the whole response to carry the information related to the request context.
For root calls both are related to the top level. For children request, both are related to that nested level.
We do this for rows, but we consider
rowCountto always be related to the top level.If we would adopt the new behavior, we would need to use
rowCountto update parent row descendants count and this looks like something you might need to do.To prevent breaking change, new behavior can be behind an experimental flag and for now we do
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 can also easily be done by caching the last row count on your own and returning it if the new response does not have this value
Uh oh!
There was an error while loading. Please reload this page.
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.
Exactly, we'll have to do it with #14527 anyways. Though I had in my mind a slightly different interface, to allow passing both the values at any nested level.
Something like:
It will provide a predictable structure with the flexibility to:
rootRowCountat any time if needed, or skip if not.undefinedvalues.To me, the current behavior of having the previous
rowCountreplaced by-1if no row count is provided with any API call is unexpected. I'd advocate for only keeping it on the very first data source call.We could possibly avoid the breaking change by adjusting the naming, so we keep the
rowCountproperty and add a new one for the current nested level, such ascurrentRowCount.The in v9, we do a breaking change
rowCount=>rootRowCountandcurrentRowCount=>rowCount, wdyt?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 have updated the behavior to be the same as in v7 to avoid breaking change.
I agree that we will need a new property when #14527 is implemented, but I will leave that to be added in the related PR.
From v9 I think that we should do the replacement
currentRowCount => rowCount(once it is added) and not have root row count processed with the children data fetch (not doingrowCount => rootRowCount).For me it is weird to get back information that is not related to my request. I have asked for the children of a specific parent. I don't expect to get back the root row count. Can you find an example of an API that does something like this?
In addition to this, providing a root row count without root rows is just half of the data I need to actually refresh my tree.