-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DataGridPro] Fix column pinning layout (#14966)
- Loading branch information
1 parent
341220a
commit 66c7b5a
Showing
7 changed files
with
101 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import * as React from 'react'; | ||
import DeleteIcon from '@mui/icons-material/Delete'; | ||
import EditIcon from '@mui/icons-material/Edit'; | ||
import { DataGridPro, GridActionsCellItem } from '@mui/x-data-grid-pro'; | ||
import { | ||
randomCreatedDate, | ||
randomTraderName, | ||
randomEmail, | ||
randomUpdatedDate, | ||
} from '@mui/x-data-grid-generator'; | ||
|
||
const columns = [ | ||
{ field: 'name', headerName: 'Name', width: 160, editable: true }, | ||
{ field: 'email', headerName: 'Email', width: 200, editable: true }, | ||
{ field: 'age', headerName: 'Age', type: 'number', editable: true }, | ||
{ | ||
field: 'dateCreated', | ||
headerName: 'Date Created', | ||
type: 'date', | ||
width: 180, | ||
editable: true, | ||
}, | ||
{ | ||
field: 'lastLogin', | ||
headerName: 'Last Login', | ||
type: 'dateTime', | ||
width: 220, | ||
editable: true, | ||
}, | ||
{ | ||
field: 'actions', | ||
type: 'actions', | ||
width: 100, | ||
getActions: () => [ | ||
<GridActionsCellItem icon={<EditIcon />} label="Edit" />, | ||
<GridActionsCellItem icon={<DeleteIcon />} label="Delete" />, | ||
], | ||
}, | ||
]; | ||
|
||
const rows = [ | ||
{ | ||
id: 1, | ||
name: randomTraderName(), | ||
email: randomEmail(), | ||
age: 25, | ||
dateCreated: randomCreatedDate(), | ||
lastLogin: randomUpdatedDate(), | ||
}, | ||
]; | ||
|
||
export default function BasicColumnPinning() { | ||
return ( | ||
<div style={{ height: 400, width: '100%' }}> | ||
<DataGridPro | ||
rows={rows} | ||
columns={columns} | ||
initialState={{ pinnedColumns: { left: ['name'], right: ['actions'] } }} | ||
/> | ||
</div> | ||
); | ||
} |