forked from mui/mui-x
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DataGrid] Add
columnGroupHeaderHeight
prop for sizing column group…
… headers (mui#14637)
- Loading branch information
1 parent
e8bc9a9
commit 24b566f
Showing
22 changed files
with
254 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import * as React from 'react'; | ||
import { DataGrid } from '@mui/x-data-grid'; | ||
|
||
const columns = [ | ||
{ field: 'id', headerName: 'ID', width: 90 }, | ||
{ | ||
field: 'firstName', | ||
headerName: 'First name', | ||
width: 150, | ||
}, | ||
{ | ||
field: 'lastName', | ||
headerName: 'Last name', | ||
width: 150, | ||
}, | ||
{ | ||
field: 'age', | ||
headerName: 'Age', | ||
type: 'number', | ||
width: 110, | ||
}, | ||
]; | ||
|
||
const rows = [ | ||
{ id: 1, lastName: 'Snow', firstName: 'Jon', age: 14 }, | ||
{ id: 2, lastName: 'Lannister', firstName: 'Cersei', age: 31 }, | ||
{ id: 3, lastName: 'Lannister', firstName: 'Jaime', age: 31 }, | ||
{ id: 4, lastName: 'Stark', firstName: 'Arya', age: 11 }, | ||
{ id: 5, lastName: 'Targaryen', firstName: 'Daenerys', age: null }, | ||
{ id: 6, lastName: 'Melisandre', firstName: null, age: 150 }, | ||
{ id: 7, lastName: 'Clifford', firstName: 'Ferrara', age: 44 }, | ||
{ id: 8, lastName: 'Frances', firstName: 'Rossini', age: 36 }, | ||
{ id: 9, lastName: 'Roxie', firstName: 'Harvey', age: 65 }, | ||
]; | ||
|
||
const columnGroupingModel = [ | ||
{ | ||
groupId: 'Internal', | ||
description: '', | ||
children: [{ field: 'id' }], | ||
}, | ||
{ | ||
groupId: 'Basic info', | ||
children: [ | ||
{ | ||
groupId: 'Full name', | ||
children: [{ field: 'lastName' }, { field: 'firstName' }], | ||
}, | ||
{ field: 'age' }, | ||
], | ||
}, | ||
]; | ||
|
||
export default function GroupHeaderHeight() { | ||
return ( | ||
<div style={{ height: 400, width: '100%' }}> | ||
<DataGrid | ||
rows={rows} | ||
columns={columns} | ||
columnGroupingModel={columnGroupingModel} | ||
columnGroupHeaderHeight={36} | ||
/> | ||
</div> | ||
); | ||
} |
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,65 @@ | ||
import * as React from 'react'; | ||
import { DataGrid, GridColDef, GridColumnGroupingModel } from '@mui/x-data-grid'; | ||
|
||
const columns: GridColDef[] = [ | ||
{ field: 'id', headerName: 'ID', width: 90 }, | ||
{ | ||
field: 'firstName', | ||
headerName: 'First name', | ||
width: 150, | ||
}, | ||
{ | ||
field: 'lastName', | ||
headerName: 'Last name', | ||
width: 150, | ||
}, | ||
{ | ||
field: 'age', | ||
headerName: 'Age', | ||
type: 'number', | ||
width: 110, | ||
}, | ||
]; | ||
|
||
const rows = [ | ||
{ id: 1, lastName: 'Snow', firstName: 'Jon', age: 14 }, | ||
{ id: 2, lastName: 'Lannister', firstName: 'Cersei', age: 31 }, | ||
{ id: 3, lastName: 'Lannister', firstName: 'Jaime', age: 31 }, | ||
{ id: 4, lastName: 'Stark', firstName: 'Arya', age: 11 }, | ||
{ id: 5, lastName: 'Targaryen', firstName: 'Daenerys', age: null }, | ||
{ id: 6, lastName: 'Melisandre', firstName: null, age: 150 }, | ||
{ id: 7, lastName: 'Clifford', firstName: 'Ferrara', age: 44 }, | ||
{ id: 8, lastName: 'Frances', firstName: 'Rossini', age: 36 }, | ||
{ id: 9, lastName: 'Roxie', firstName: 'Harvey', age: 65 }, | ||
]; | ||
|
||
const columnGroupingModel: GridColumnGroupingModel = [ | ||
{ | ||
groupId: 'Internal', | ||
description: '', | ||
children: [{ field: 'id' }], | ||
}, | ||
{ | ||
groupId: 'Basic info', | ||
children: [ | ||
{ | ||
groupId: 'Full name', | ||
children: [{ field: 'lastName' }, { field: 'firstName' }], | ||
}, | ||
{ field: 'age' }, | ||
], | ||
}, | ||
]; | ||
|
||
export default function GroupHeaderHeight() { | ||
return ( | ||
<div style={{ height: 400, width: '100%' }}> | ||
<DataGrid | ||
rows={rows} | ||
columns={columns} | ||
columnGroupingModel={columnGroupingModel} | ||
columnGroupHeaderHeight={36} | ||
/> | ||
</div> | ||
); | ||
} |
6 changes: 6 additions & 0 deletions
6
docs/data/data-grid/column-groups/GroupHeaderHeight.tsx.preview
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,6 @@ | ||
<DataGrid | ||
rows={rows} | ||
columns={columns} | ||
columnGroupingModel={columnGroupingModel} | ||
columnGroupHeaderHeight={36} | ||
/> |
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,28 @@ | ||
import * as React from 'react'; | ||
import { DataGrid } from '@mui/x-data-grid'; | ||
|
||
const rows = [ | ||
{ | ||
id: 1, | ||
username: '@MUI', | ||
age: 20, | ||
}, | ||
]; | ||
|
||
const columns = [ | ||
{ | ||
field: 'username', | ||
headerName: 'Username', | ||
description: | ||
'The identification used by the person with access to the online service.', | ||
}, | ||
{ field: 'age', headerName: 'Age' }, | ||
]; | ||
|
||
export default function HeaderHeight() { | ||
return ( | ||
<div style={{ height: 250, width: '100%' }}> | ||
<DataGrid columns={columns} rows={rows} columnHeaderHeight={36} /> | ||
</div> | ||
); | ||
} |
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,28 @@ | ||
import * as React from 'react'; | ||
import { DataGrid, GridColDef } from '@mui/x-data-grid'; | ||
|
||
const rows = [ | ||
{ | ||
id: 1, | ||
username: '@MUI', | ||
age: 20, | ||
}, | ||
]; | ||
|
||
const columns: GridColDef[] = [ | ||
{ | ||
field: 'username', | ||
headerName: 'Username', | ||
description: | ||
'The identification used by the person with access to the online service.', | ||
}, | ||
{ field: 'age', headerName: 'Age' }, | ||
]; | ||
|
||
export default function HeaderHeight() { | ||
return ( | ||
<div style={{ height: 250, width: '100%' }}> | ||
<DataGrid columns={columns} rows={rows} columnHeaderHeight={36} /> | ||
</div> | ||
); | ||
} |
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 @@ | ||
<DataGrid columns={columns} rows={rows} columnHeaderHeight={36} /> |
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
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
Oops, something went wrong.