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] Add DataGridCssVars regression demo #14662

Merged
merged 1 commit into from
Sep 19, 2024
Merged
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
69 changes: 69 additions & 0 deletions test/regressions/data-grid/DataGridCssVars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
import * as React from 'react';
import { DataGridPro } from '@mui/x-data-grid-pro';
import {
randomCreatedDate,
randomTraderName,
randomEmail,
randomUpdatedDate,
} from '@mui/x-data-grid-generator';
import { Box, Experimental_CssVarsProvider as CssVarsProvider } from '@mui/material';

export default function ControlPinnedColumns() {
const [pinnedColumns, setPinnedColumns] = React.useState({
left: ['name'],
right: ['dateCreated'],
});

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

return (
<Box sx={{ height: 400, width: 400 }}>
<CssVarsProvider>
<DataGridPro
rows={rows}
hideFooter
columns={columns}
pinnedColumns={pinnedColumns}
onPinnedColumnsChange={handlePinnedColumnsChange}
/>
</CssVarsProvider>
</Box>
);
}

const columns = [
{ field: 'name', headerName: 'Name', width: 80, editable: true },
{ field: 'email', headerName: 'Email', width: 150, editable: true },
{ field: 'age', headerName: 'Age', type: 'number', editable: true },
{
field: 'dateCreated',
headerName: 'Date Created',
type: 'date',
width: 80,
editable: true,
},
{
field: 'lastLogin',
headerName: 'Last Login',
type: 'dateTime',
width: 180,
editable: true,
},
];

const rows = [
{
id: 1,
name: randomTraderName(),
email: randomEmail(),
age: 25,
dateCreated: randomCreatedDate(),
lastLogin: randomUpdatedDate(),
},
];
Loading