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 columnGroupingModel #5133

Merged
merged 56 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
1333b0a
doc
alexfauquette Jun 23, 2022
395030b
scripts
alexfauquette Jun 23, 2022
4c513de
first implementation
alexfauquette Jun 23, 2022
0a11d17
update style
alexfauquette Jun 24, 2022
22782a0
move column hydratation in a dedicated hook
alexfauquette Jul 2, 2022
2227d0c
Merge remote-tracking branch 'upstream/master' into columnGroup
alexfauquette Jul 6, 2022
8e42932
add some tests
alexfauquette Jul 6, 2022
9c33fe2
add and fix tests
alexfauquette Jul 7, 2022
d5f0939
add test
alexfauquette Jul 7, 2022
a01c4ea
use same components for column and group headers
alexfauquette Jul 8, 2022
373b04e
fix height inconsitencies
alexfauquette Jul 8, 2022
0d52b8e
typo feedbacks
alexfauquette Jul 11, 2022
83144c4
feedbacks on doc
alexfauquette Jul 11, 2022
a82db7b
type documentation
alexfauquette Jul 11, 2022
8bb4b2e
Apply suggestions about documentation
alexfauquette Jul 27, 2022
1fe45f4
small suggestions
alexfauquette Jul 27, 2022
8304b84
factorise code with one function for common part between getColumHead…
alexfauquette Jul 27, 2022
2d0f25a
reduce API surface
alexfauquette Jul 27, 2022
a750d7b
scripts
alexfauquette Jul 27, 2022
9584426
move column grouping hooks to a special folder
alexfauquette Jul 28, 2022
b04a77b
Merge remote-tracking branch 'upstream/master' into columnGroup
alexfauquette Jul 28, 2022
817fc2e
scripts
alexfauquette Jul 28, 2022
1b60a02
feedbacks
alexfauquette Jul 28, 2022
8135419
make grouping experimental
alexfauquette Jul 29, 2022
6d3f4ba
doc updates
alexfauquette Jul 29, 2022
93311d7
distingush header and group header events
alexfauquette Aug 1, 2022
fb650a5
TS fix
alexfauquette Aug 1, 2022
db1663e
use helper function for groupheaders selection
alexfauquette Aug 1, 2022
9f88ee2
feedbacks
alexfauquette Aug 1, 2022
d3445a1
avoid error verification at each depth level
alexfauquette Aug 2, 2022
d0c36e4
allows to remove and add grouping
alexfauquette Aug 2, 2022
5ce33b1
yarn docs:api
alexfauquette Aug 2, 2022
c4899e8
split empty cell when not from the same group
alexfauquette Aug 2, 2022
28dcb05
improve group style
alexfauquette Aug 2, 2022
956b026
scripts
alexfauquette Aug 2, 2022
16ffc9c
fix tests
alexfauquette Aug 2, 2022
4049f00
helper simplification
alexfauquette Aug 2, 2022
e638a90
wrapp field to avoid wrong overlapping string
alexfauquette Aug 2, 2022
0fc9a80
Apply suggestions from code review
alexfauquette Aug 2, 2022
0d2b6f3
fix styling
alexfauquette Aug 3, 2022
d595a72
add message for experimental flag
alexfauquette Aug 3, 2022
82011e2
fix prettier style
oliviertassinari Aug 4, 2022
552d6cd
Olivier style feedbacks
alexfauquette Aug 5, 2022
54d492e
Mathews feedback
alexfauquette Aug 9, 2022
64b382f
scripts and remove useless editing
alexfauquette Aug 9, 2022
dac5a1d
allows to add headerClassName to column group
alexfauquette Aug 9, 2022
28642b3
fix resize
alexfauquette Aug 10, 2022
af268e7
demo naming fixes
alexfauquette Aug 10, 2022
6e2cc8f
allows to move column between hidden ones
alexfauquette Aug 10, 2022
2bb9569
use computed width
alexfauquette Aug 12, 2022
2c5ff80
Andrew feedbacks
alexfauquette Aug 12, 2022
552f226
feedbacks
alexfauquette Aug 16, 2022
c2d9457
Merge remote-tracking branch 'upstream/master' into columnGroup
alexfauquette Aug 16, 2022
7eaccb3
proptypes
alexfauquette Aug 16, 2022
1f71d42
proptypes with up to date packages
alexfauquette Aug 16, 2022
e6e383e
use same heigh for column header and group header
alexfauquette Aug 23, 2022
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
67 changes: 67 additions & 0 deletions docs/data/data-grid/column-groups/BasicGroupingDemo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import * as React from 'react';
import { DataGridPro } from '@mui/x-data-grid-pro';

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: 35 },
{ id: 2, lastName: 'Lannister', firstName: 'Cersei', age: 42 },
{ id: 3, lastName: 'Lannister', firstName: 'Jaime', age: 45 },
{ id: 4, lastName: 'Stark', firstName: 'Arya', age: 16 },
{ 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 BasicGroupingDemo() {
return (
<div style={{ height: 400, width: '100%' }}>
<DataGridPro
experimentalFeatures={{ columnGrouping: true }}
rows={rows}
columns={columns}
checkboxSelection
disableSelectionOnClick
columnGroupingModel={columnGroupingModel}
/>
</div>
);
}
71 changes: 71 additions & 0 deletions docs/data/data-grid/column-groups/BasicGroupingDemo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import * as React from 'react';
import {
DataGridPro,
GridColDef,
GridColumnGroupingModel,
} from '@mui/x-data-grid-pro';

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: 35 },
{ id: 2, lastName: 'Lannister', firstName: 'Cersei', age: 42 },
{ id: 3, lastName: 'Lannister', firstName: 'Jaime', age: 45 },
{ id: 4, lastName: 'Stark', firstName: 'Arya', age: 16 },
{ 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 BasicGroupingDemo() {
alexfauquette marked this conversation as resolved.
Show resolved Hide resolved
return (
<div style={{ height: 400, width: '100%' }}>
<DataGridPro
experimentalFeatures={{ columnGrouping: true }}
rows={rows}
columns={columns}
checkboxSelection
disableSelectionOnClick
columnGroupingModel={columnGroupingModel}
/>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<DataGridPro
experimentalFeatures={{ columnGrouping: true }}
rows={rows}
columns={columns}
checkboxSelection
disableSelectionOnClick
columnGroupingModel={columnGroupingModel}
/>
65 changes: 65 additions & 0 deletions docs/data/data-grid/column-groups/BreakingGroupDemo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import * as React from 'react';
import { DataGridPro } from '@mui/x-data-grid-pro';

const columns = [
{ field: 'id', headerName: 'ID', width: 100 },
{ field: 'isAdmin', type: 'boolean', headerName: 'is admin', width: 100 },
{
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, isAdmin: false, lastName: 'Snow', firstName: 'Jon', age: 35 },
{ id: 2, isAdmin: true, lastName: 'Lannister', firstName: 'Cersei', age: 42 },
{ id: 3, isAdmin: false, lastName: 'Lannister', firstName: 'Jaime', age: 45 },
{ id: 4, isAdmin: false, lastName: 'Stark', firstName: 'Arya', age: 16 },
{ id: 5, isAdmin: true, lastName: 'Targaryen', firstName: 'Daenerys', age: null },
{ id: 6, isAdmin: true, lastName: 'Melisandre', firstName: null, age: 150 },
{ id: 7, isAdmin: false, lastName: 'Clifford', firstName: 'Ferrara', age: 44 },
{ id: 8, isAdmin: false, lastName: 'Frances', firstName: 'Rossini', age: 36 },
{ id: 9, isAdmin: false, lastName: 'Roxie', firstName: 'Harvey', age: 65 },
];

const columnGroupingModel = [
{
groupId: 'internal_data',
headerName: 'Internal (not freeReordering)',
description: '',
children: [{ field: 'id' }, { field: 'isAdmin' }],
},
{
groupId: 'naming',
headerName: 'Full name (freeReordering)',
freeReordering: true,
children: [{ field: 'lastName' }, { field: 'firstName' }],
},
];

export default function BreakingGroupDemo() {
return (
<div style={{ height: 400, width: '100%' }}>
<DataGridPro
rows={rows}
columns={columns}
experimentalFeatures={{ columnGrouping: true }}
checkboxSelection
disableSelectionOnClick
columnGroupingModel={columnGroupingModel}
/>
</div>
);
}
69 changes: 69 additions & 0 deletions docs/data/data-grid/column-groups/BreakingGroupDemo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import * as React from 'react';
import {
DataGridPro,
GridColDef,
GridColumnGroupingModel,
} from '@mui/x-data-grid-pro';

const columns: GridColDef[] = [
{ field: 'id', headerName: 'ID', width: 100 },
{ field: 'isAdmin', type: 'boolean', headerName: 'is admin', width: 100 },
{
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, isAdmin: false, lastName: 'Snow', firstName: 'Jon', age: 35 },
{ id: 2, isAdmin: true, lastName: 'Lannister', firstName: 'Cersei', age: 42 },
{ id: 3, isAdmin: false, lastName: 'Lannister', firstName: 'Jaime', age: 45 },
{ id: 4, isAdmin: false, lastName: 'Stark', firstName: 'Arya', age: 16 },
{ id: 5, isAdmin: true, lastName: 'Targaryen', firstName: 'Daenerys', age: null },
{ id: 6, isAdmin: true, lastName: 'Melisandre', firstName: null, age: 150 },
{ id: 7, isAdmin: false, lastName: 'Clifford', firstName: 'Ferrara', age: 44 },
{ id: 8, isAdmin: false, lastName: 'Frances', firstName: 'Rossini', age: 36 },
{ id: 9, isAdmin: false, lastName: 'Roxie', firstName: 'Harvey', age: 65 },
];

const columnGroupingModel: GridColumnGroupingModel = [
{
groupId: 'internal_data',
headerName: 'Internal (not freeReordering)',
description: '',
children: [{ field: 'id' }, { field: 'isAdmin' }],
},
{
groupId: 'naming',
headerName: 'Full name (freeReordering)',
freeReordering: true,
children: [{ field: 'lastName' }, { field: 'firstName' }],
},
];

export default function BreakingGroupDemo() {
return (
<div style={{ height: 400, width: '100%' }}>
<DataGridPro
rows={rows}
columns={columns}
experimentalFeatures={{ columnGrouping: true }}
checkboxSelection
disableSelectionOnClick
columnGroupingModel={columnGroupingModel}
/>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<DataGridPro
rows={rows}
columns={columns}
experimentalFeatures={{ columnGrouping: true }}
checkboxSelection
disableSelectionOnClick
columnGroupingModel={columnGroupingModel}
/>
Loading