[data grid] rowCount
set to -1
when fetching child rows in server-side Tree Data
#17626
Labels
bug 🐛
Something doesn't work
component: data grid
This is the name of the generic UI component, not the React module!
feature: Server integration
Better integration with backends, e.g. data source
feature: Tree data
Related to the data grid Tree data feature
Steps to reproduce
Description
After upgrading from DataGrid v7 to v8, we're experiencing an issue with server-side rendering in tree view mode. When expanding a parent row to fetch its children, DataGrid v8 incorrectly sets
rowCount
to -1 if the server response doesn't include a total row count.In v7, the DataGrid correctly maintained the existing row count when fetching child rows. However, in v8, it seems to reset the row count to -1 when loading children, causing pagination issues.
Steps to Reproduce
Current behavior
MUI X: useGridRowCount - Setting 'rowCount' to -1
gridPageCountSelector
returns an incorrect page count (2 in our case - got this value fromconst pageCount = useGridSelector(apiRef, gridPageCountSelector);
)Expected behavior
Context
We're using DataGrid with server-side pagination and tree data. Our goal is to hide pagination when the total number of rows fits within a single page (totalRows ≤ pageSize or pageCount ≤ 1).
This worked correctly in v7, but after upgrading to v8, we're experiencing an issue where expanding a parent row to fetch its children causes DataGrid to incorrectly set
rowCount
to -1, which then causes pagination to appear when it shouldn't.Additional Context
In our logs, we can see:
MUI X: useGridRowCount - Setting 'rowCount' to 15
MUI X: useGridRowCount - Setting 'rowCount' to -1
This appears to be a regression from v7, where the DataGrid correctly handled this scenario.
Workaround
Currently, we're forced to return the total row count with every request, including child row requests, even though this information is redundant for child fetching operations.
Your environment
Browser: tested in Chrome & Brave Browser
Search keywords: bug, regression, DataGrid, server-side pagination, tree data, rowCount, v8, Pagination, Custom pagintaion
The text was updated successfully, but these errors were encountered: