Skip to content
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

[DataGrid] Dynamic virtualization range #12353

Merged
merged 39 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9043276
feat: pixel buffers instead of item buffers
romgrk Mar 6, 2024
4dadf5c
feat: scroll position prediction
romgrk Mar 6, 2024
8742d37
feat: predict with linear regression
romgrk Mar 7, 2024
82e24c2
feat: more simple buffer
romgrk Mar 7, 2024
036fc26
lint
romgrk Mar 7, 2024
3453534
Merge branch 'next' into feat-virtualization-range
romgrk Mar 7, 2024
54564fb
ci: run
romgrk Mar 8, 2024
3d73f8f
feat: finish buffer changes
romgrk Mar 9, 2024
272ae19
doc: update guide
romgrk Mar 9, 2024
f49842e
lint
romgrk Mar 9, 2024
7a5cb7b
lint
romgrk Mar 9, 2024
3d69375
lint
romgrk Mar 9, 2024
1a8f08d
lint
romgrk Mar 9, 2024
7171c7c
Merge branch 'next' into feat-virtualization-range
romgrk Mar 10, 2024
239c512
feat: render context rework
romgrk Mar 11, 2024
241b730
lint
romgrk Mar 11, 2024
8ab7b5b
feat: remove props
romgrk Mar 12, 2024
5fedc09
lint
romgrk Mar 12, 2024
33ad4ed
lint
romgrk Mar 12, 2024
026a6f6
lint
romgrk Mar 12, 2024
6ef0ec5
Merge branch 'next' into feat-virtualization-range
romgrk Mar 12, 2024
a996bb4
lint
romgrk Mar 12, 2024
1c04d64
lint
romgrk Mar 12, 2024
df5f06b
Update docs/data/migration/migration-data-grid-v6/migration-data-grid…
romgrk Mar 13, 2024
156d9fe
Merge branch 'next' into feat-virtualization-range
romgrk Mar 14, 2024
27c77d7
Merge branch 'feat-virtualization-range' of github.com:romgrk/mui-x i…
romgrk Mar 14, 2024
ca76f30
lint
romgrk Mar 14, 2024
ab1052c
refactor: column width as constant
romgrk Mar 14, 2024
f489228
lint
romgrk Mar 14, 2024
1b5ef93
lint
romgrk Mar 14, 2024
b492aac
lint
romgrk Mar 14, 2024
ee8c402
Merge branch 'next' into feat-virtualization-range
romgrk Mar 14, 2024
9ac297b
test: disable virtualization in jsdom
romgrk Mar 15, 2024
d43b2a8
lint
romgrk Mar 15, 2024
97defb7
fix: async autosizing demo
romgrk Mar 19, 2024
6704b08
Merge branch 'next' into feat-virtualization-range
romgrk Mar 19, 2024
4d45e22
lint
romgrk Mar 19, 2024
93d9bbd
Merge branch 'next' into feat-virtualization-range
romgrk Mar 20, 2024
a5db4a4
lint
romgrk Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/data/data-grid/demo/FullFeaturedDemo.js
romgrk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export default function FullFeaturedDemo() {
loading={loading}
checkboxSelection
disableRowSelectionOnClick
rowThreshold={0}
rowThresholdPx={0}
initialState={{
...data.initialState,
pinnedColumns: { left: [GRID_CHECKBOX_SELECTION_FIELD, 'desk'] },
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/demo/FullFeaturedDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export default function FullFeaturedDemo() {
loading={loading}
checkboxSelection
disableRowSelectionOnClick
rowThreshold={0}
rowThresholdPx={0}
initialState={{
...data.initialState,
pinnedColumns: { left: [GRID_CHECKBOX_SELECTION_FIELD, 'desk'] },
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/master-detail/BasicDetailPanels.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default function BasicDetailPanels() {
<DataGridPro
columns={columns}
rows={rows}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
/>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/master-detail/BasicDetailPanels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export default function BasicDetailPanels() {
<DataGridPro
columns={columns}
rows={rows}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<DataGridPro
columns={columns}
rows={rows}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
/>
2 changes: 1 addition & 1 deletion docs/data/data-grid/master-detail/ControlMasterDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function ControlMasterDetail() {
<DataGridPro
rows={rows}
columns={columns}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelContent={({ row }) => (
<Box sx={{ p: 2 }}>{`Order #${row.id}`}</Box>
)}
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/master-detail/ControlMasterDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function ControlMasterDetail() {
<DataGridPro
rows={rows}
columns={columns}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelContent={({ row }) => (
<Box sx={{ p: 2 }}>{`Order #${row.id}`}</Box>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function CustomizeDetailPanelToggle() {
<DataGridPro
rows={rows}
columns={columns}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelContent={getDetailPanelContent}
getDetailPanelHeight={getDetailPanelHeight}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function CustomizeDetailPanelToggle() {
<DataGridPro
rows={rows}
columns={columns}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelContent={getDetailPanelContent}
getDetailPanelHeight={getDetailPanelHeight}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<DataGridPro
rows={rows}
columns={columns}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelContent={getDetailPanelContent}
getDetailPanelHeight={getDetailPanelHeight}
/>
2 changes: 1 addition & 1 deletion docs/data/data-grid/master-detail/DetailPanelAutoHeight.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export default function DetailPanelAutoHeight() {
<DataGridPro
columns={columns}
rows={rows}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export default function DetailPanelAutoHeight() {
<DataGridPro
columns={columns}
rows={rows}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<DataGridPro
columns={columns}
rows={rows}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
/>
2 changes: 1 addition & 1 deletion docs/data/data-grid/master-detail/FormDetailPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default function FormDetailPanel() {
<DataGridPro
columns={columns}
rows={rows}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
/>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/master-detail/FormDetailPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default function FormDetailPanel() {
<DataGridPro
columns={columns}
rows={rows}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<DataGridPro
columns={columns}
rows={rows}
rowThreshold={0}
rowThresholdPx={0}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
/>
2 changes: 1 addition & 1 deletion docs/data/data-grid/master-detail/FullWidthDetailPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export default function FullWidthDetailPanel() {
<DataGridPro
columns={columns}
rows={rows}
rowThreshold={0}
rowThresholdPx={0}
pinnedColumns={{ left: [GRID_DETAIL_PANEL_TOGGLE_FIELD] }}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/master-detail/FullWidthDetailPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default function FullWidthDetailPanel() {
<DataGridPro
columns={columns}
rows={rows}
rowThreshold={0}
rowThresholdPx={0}
pinnedColumns={{ left: [GRID_DETAIL_PANEL_TOGGLE_FIELD] }}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<DataGridPro
columns={columns}
rows={rows}
rowThreshold={0}
rowThresholdPx={0}
pinnedColumns={{ left: [GRID_DETAIL_PANEL_TOGGLE_FIELD] }}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
Expand Down
4 changes: 2 additions & 2 deletions docs/data/data-grid/master-detail/master-detail.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ const getDetailPanelContent = React.useCallback(() => { ... }, []);

Depending on the height of the detail panel, you may see a blank space when scrolling.
This is caused by the data grid using a lazy approach to update the rendered rows.
Set `rowThreshold` to 0 to force new rows to be rendered more often to fill the blank space.
Set `rowThresholdPx` to a lower value to force new rows to be rendered more often to fill the blank space.
Note that this may reduce the performance.

```tsx
<DataGridPro rowThreshold={0} />
<DataGridPro rowThresholdPx={20} />
```

:::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function ColumnVirtualizationGrid() {

return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid {...data} columnBuffer={2} columnThreshold={2} />
<DataGrid {...data} columnBufferPx={100} columnThresholdPx={100} />
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function ColumnVirtualizationGrid() {

return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid {...data} columnBuffer={2} columnThreshold={2} />
<DataGrid {...data} columnBufferPx={100} columnThresholdPx={100} />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<DataGrid {...data} columnBuffer={2} columnThreshold={2} />
<DataGrid {...data} columnBufferPx={100} columnThresholdPx={100} />
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ As a result, the following changes have been made:
- Pinned row and column sections are now contained in the virtual scroller.
- The cell inner wrapper `.MuiDataGrid-cellContent` has been removed.

<!-- ### Renamed props
## Renamed props

- -->
- The props `rowBuffer`, `columnBuffer`, `rowThreshold` and `columnThreshold` were renamed to `rowBufferPx`, `columnBufferPx`, `rowThresholdPx` and `columnThresholdPx`.
romgrk marked this conversation as resolved.
Show resolved Hide resolved
Their value is now a pixel value rather than a number of items. Their default value is now `150`.

### Removed props

Expand Down
8 changes: 4 additions & 4 deletions docs/pages/x/api/data-grid/data-grid-premium.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
"checkboxSelectionVisibleOnly": { "type": { "name": "bool" }, "default": "false" },
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"clipboardCopyCellDelimiter": { "type": { "name": "string" }, "default": "'\\t'" },
"columnBuffer": { "type": { "name": "number" }, "default": "3" },
"columnBufferPx": { "type": { "name": "number" }, "default": "100" },
"columnHeaderHeight": { "type": { "name": "number" }, "default": "56" },
"columnThreshold": { "type": { "name": "number" }, "default": "3" },
"columnThresholdPx": { "type": { "name": "number" }, "default": "150" },
"columnVisibilityModel": { "type": { "name": "object" } },
"defaultGroupingExpansionDepth": { "type": { "name": "number" }, "default": "0" },
"density": {
Expand Down Expand Up @@ -541,7 +541,7 @@
"returned": "Promise<R> | R"
}
},
"rowBuffer": { "type": { "name": "number" }, "default": "3" },
"rowBufferPx": { "type": { "name": "number" }, "default": "100" },
"rowCount": { "type": { "name": "number" } },
"rowGroupingColumnMode": {
"type": { "name": "enum", "description": "'multiple'<br>&#124;&nbsp;'single'" },
Expand All @@ -566,7 +566,7 @@
"type": { "name": "enum", "description": "'border'<br>&#124;&nbsp;'margin'" },
"default": "\"margin\""
},
"rowThreshold": { "type": { "name": "number" }, "default": "3" },
"rowThresholdPx": { "type": { "name": "number" }, "default": "150" },
"scrollbarSize": { "type": { "name": "number" } },
"scrollEndThreshold": { "type": { "name": "number" }, "default": "80" },
"showCellVerticalBorder": { "type": { "name": "bool" }, "default": "false" },
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/x/api/data-grid/data-grid-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"checkboxSelectionVisibleOnly": { "type": { "name": "bool" }, "default": "false" },
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"clipboardCopyCellDelimiter": { "type": { "name": "string" }, "default": "'\\t'" },
"columnBuffer": { "type": { "name": "number" }, "default": "3" },
"columnBufferPx": { "type": { "name": "number" }, "default": "100" },
"columnHeaderHeight": { "type": { "name": "number" }, "default": "56" },
"columnThreshold": { "type": { "name": "number" }, "default": "3" },
"columnThresholdPx": { "type": { "name": "number" }, "default": "150" },
"columnVisibilityModel": { "type": { "name": "object" } },
"defaultGroupingExpansionDepth": { "type": { "name": "number" }, "default": "0" },
"density": {
Expand Down Expand Up @@ -488,7 +488,7 @@
"returned": "Promise<R> | R"
}
},
"rowBuffer": { "type": { "name": "number" }, "default": "3" },
"rowBufferPx": { "type": { "name": "number" }, "default": "100" },
"rowCount": { "type": { "name": "number" } },
"rowHeight": { "type": { "name": "number" }, "default": "52" },
"rowModesModel": { "type": { "name": "object" } },
Expand All @@ -508,7 +508,7 @@
"type": { "name": "enum", "description": "'border'<br>&#124;&nbsp;'margin'" },
"default": "\"margin\""
},
"rowThreshold": { "type": { "name": "number" }, "default": "3" },
"rowThresholdPx": { "type": { "name": "number" }, "default": "150" },
"scrollbarSize": { "type": { "name": "number" } },
"scrollEndThreshold": { "type": { "name": "number" }, "default": "80" },
"showCellVerticalBorder": { "type": { "name": "bool" }, "default": "false" },
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/x/api/data-grid/data-grid.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"checkboxSelection": { "type": { "name": "bool" }, "default": "false" },
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"clipboardCopyCellDelimiter": { "type": { "name": "string" }, "default": "'\\t'" },
"columnBuffer": { "type": { "name": "number" }, "default": "3" },
"columnBufferPx": { "type": { "name": "number" }, "default": "100" },
"columnHeaderHeight": { "type": { "name": "number" }, "default": "56" },
"columnThreshold": { "type": { "name": "number" }, "default": "3" },
"columnThresholdPx": { "type": { "name": "number" }, "default": "150" },
"columnVisibilityModel": { "type": { "name": "object" } },
"density": {
"type": {
Expand Down Expand Up @@ -379,7 +379,7 @@
"returned": "Promise<R> | R"
}
},
"rowBuffer": { "type": { "name": "number" }, "default": "3" },
"rowBufferPx": { "type": { "name": "number" }, "default": "100" },
"rowCount": { "type": { "name": "number" } },
"rowHeight": { "type": { "name": "number" }, "default": "52" },
"rowModesModel": { "type": { "name": "object" } },
Expand All @@ -395,7 +395,7 @@
"type": { "name": "enum", "description": "'border'<br>&#124;&nbsp;'margin'" },
"default": "\"margin\""
},
"rowThreshold": { "type": { "name": "number" }, "default": "3" },
"rowThresholdPx": { "type": { "name": "number" }, "default": "150" },
"scrollbarSize": { "type": { "name": "number" } },
"showCellVerticalBorder": { "type": { "name": "bool" }, "default": "false" },
"showColumnVerticalBorder": { "type": { "name": "bool" }, "default": "false" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@
"clipboardCopyCellDelimiter": {
"description": "The character used to separate cell values when copying to the clipboard."
},
"columnBuffer": {
"description": "Number of extra columns to be rendered before/after the visible slice."
},
"columnBufferPx": { "description": "Column region to render before/after the viewport" },
"columnHeaderHeight": {
"description": "Sets the height in pixel of the column headers in the Data Grid."
},
"columns": {
"description": "Set of columns of type <a href='/x/api/data-grid/grid-col-def/'>GridColDef</a>[]."
},
"columnThreshold": {
"columnThresholdPx": {
"description": "Number of rows from the <code>columnBuffer</code> that can be visible before a new slice is rendered."
},
"columnVisibilityModel": {
Expand Down Expand Up @@ -566,9 +564,7 @@
"Promise<R> | R": "The final values to update the row."
}
},
"rowBuffer": {
"description": "Number of extra rows to be rendered before/after the visible slice."
},
"rowBufferPx": { "description": "Row region to render before/after the viewport" },
"rowCount": {
"description": "Set the total number of rows, if it is different from the length of the value <code>rows</code> prop. If some rows have children (for instance in the tree data), this number represents the amount of top level rows."
},
Expand All @@ -591,7 +587,7 @@
"rowSpacingType": {
"description": "Sets the type of space between rows added by <code>getRowSpacing</code>."
},
"rowThreshold": {
"rowThresholdPx": {
"description": "Number of rows from the <code>rowBuffer</code> that can be visible before a new slice is rendered."
},
"scrollbarSize": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@
"clipboardCopyCellDelimiter": {
"description": "The character used to separate cell values when copying to the clipboard."
},
"columnBuffer": {
"description": "Number of extra columns to be rendered before/after the visible slice."
},
"columnBufferPx": { "description": "Column region to render before/after the viewport" },
"columnHeaderHeight": {
"description": "Sets the height in pixel of the column headers in the Data Grid."
},
"columns": {
"description": "Set of columns of type <a href='/x/api/data-grid/grid-col-def/'>GridColDef</a>[]."
},
"columnThreshold": {
"columnThresholdPx": {
"description": "Number of rows from the <code>columnBuffer</code> that can be visible before a new slice is rendered."
},
"columnVisibilityModel": {
Expand Down Expand Up @@ -516,9 +514,7 @@
"Promise<R> | R": "The final values to update the row."
}
},
"rowBuffer": {
"description": "Number of extra rows to be rendered before/after the visible slice."
},
"rowBufferPx": { "description": "Row region to render before/after the viewport" },
"rowCount": {
"description": "Set the total number of rows, if it is different from the length of the value <code>rows</code> prop. If some rows have children (for instance in the tree data), this number represents the amount of top level rows."
},
Expand All @@ -537,7 +533,7 @@
"rowSpacingType": {
"description": "Sets the type of space between rows added by <code>getRowSpacing</code>."
},
"rowThreshold": {
"rowThresholdPx": {
"description": "Number of rows from the <code>rowBuffer</code> that can be visible before a new slice is rendered."
},
"scrollbarSize": {
Expand Down
Loading
Loading