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

[docs] Fix column pinning for "Disable detail panel content scroll" section #14854

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 10 additions & 1 deletion docs/data/data-grid/master-detail/FullWidthDetailPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,21 @@ export default function FullWidthDetailPanel() {

const getDetailPanelHeight = React.useCallback(() => 400, []);

const [pinnedColumns, setPinnedColumns] = React.useState({
left: [GRID_DETAIL_PANEL_TOGGLE_FIELD],
});

const handlePinnedColumnsChange = React.useCallback((updatedPinnedColumns) => {
setPinnedColumns(updatedPinnedColumns);
}, []);

return (
<Box sx={{ width: '100%', height: 400 }}>
<DataGridPro
columns={columns}
rows={rows}
pinnedColumns={{ left: [GRID_DETAIL_PANEL_TOGGLE_FIELD] }}
pinnedColumns={pinnedColumns}
onPinnedColumnsChange={handlePinnedColumnsChange}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
sx={{
Expand Down
17 changes: 15 additions & 2 deletions docs/data/data-grid/master-detail/FullWidthDetailPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import {
DataGridPro,
GridColDef,
useGridApiContext,
GRID_DETAIL_PANEL_TOGGLE_FIELD,
GridRowParams,
GRID_DETAIL_PANEL_TOGGLE_FIELD,
GridPinnedColumnFields,
} from '@mui/x-data-grid-pro';
import {
randomCreatedDate,
Expand Down Expand Up @@ -200,12 +201,24 @@ export default function FullWidthDetailPanel() {

const getDetailPanelHeight = React.useCallback(() => 400, []);

const [pinnedColumns, setPinnedColumns] = React.useState<GridPinnedColumnFields>({
left: [GRID_DETAIL_PANEL_TOGGLE_FIELD],
});

const handlePinnedColumnsChange = React.useCallback(
(updatedPinnedColumns: GridPinnedColumnFields) => {
setPinnedColumns(updatedPinnedColumns);
},
[],
);

return (
<Box sx={{ width: '100%', height: 400 }}>
<DataGridPro
columns={columns}
rows={rows}
pinnedColumns={{ left: [GRID_DETAIL_PANEL_TOGGLE_FIELD] }}
kalyan90 marked this conversation as resolved.
Show resolved Hide resolved
pinnedColumns={pinnedColumns}
onPinnedColumnsChange={handlePinnedColumnsChange}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
sx={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<DataGridPro
columns={columns}
rows={rows}
pinnedColumns={{ left: [GRID_DETAIL_PANEL_TOGGLE_FIELD] }}
pinnedColumns={pinnedColumns}
onPinnedColumnsChange={handlePinnedColumnsChange}
getDetailPanelHeight={getDetailPanelHeight}
getDetailPanelContent={getDetailPanelContent}
sx={{
Expand Down