diff --git a/packages/x-data-grid-pro/src/hooks/features/dataSource/useGridDataSourceBasePro.ts b/packages/x-data-grid-pro/src/hooks/features/dataSource/useGridDataSourceBasePro.ts index d1fc3e6e4f72a..0e35bd852ba66 100644 --- a/packages/x-data-grid-pro/src/hooks/features/dataSource/useGridDataSourceBasePro.ts +++ b/packages/x-data-grid-pro/src/hooks/features/dataSource/useGridDataSourceBasePro.ts @@ -129,7 +129,9 @@ export const useGridDataSourceBasePro = ( const rows = cachedData.rows; nestedDataManager.setRequestSettled(id); apiRef.current.updateNestedRows(rows, rowNode.path); - apiRef.current.setRowCount(cachedData.rowCount === undefined ? -1 : cachedData.rowCount); + if (cachedData.rowCount !== undefined) { + apiRef.current.setRowCount(cachedData.rowCount); + } apiRef.current.setRowChildrenExpansion(id, true); apiRef.current.dataSource.setChildrenLoading(id, false); return; @@ -158,9 +160,9 @@ export const useGridDataSourceBasePro = ( cache.set(key, response); }); - apiRef.current.setRowCount( - getRowsResponse.rowCount === undefined ? -1 : getRowsResponse.rowCount, - ); + if (getRowsResponse.rowCount !== undefined) { + apiRef.current.setRowCount(getRowsResponse.rowCount); + } // Remove existing outdated rows before setting the new ones const rowsToDelete: GridRowModelUpdate[] = []; getRowsResponse.rows.forEach((row) => {