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] Improved column menu design and api #6619

Merged
merged 114 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
b109ff5
Improves column menu
MBilalShafi Oct 24, 2022
b6bdee4
Does some visual updates as per discussion
MBilalShafi Oct 25, 2022
c466fac
Runs scripts
MBilalShafi Oct 25, 2022
ad09883
Runs scripts
MBilalShafi Oct 25, 2022
18e526f
Runs scripts
MBilalShafi Oct 25, 2022
533c11c
Improves logic and adjusts styling
MBilalShafi Oct 27, 2022
9384d9c
Improves logic
MBilalShafi Oct 27, 2022
a5b615b
Updates designs on a few components
MBilalShafi Oct 28, 2022
794c56f
Updates interfaces and CSS as per discussions
MBilalShafi Oct 28, 2022
efbaff2
Removes localization change
MBilalShafi Oct 28, 2022
f7ee267
Allows disabling, removing, reordering, adding of menu items and oth…
MBilalShafi Nov 2, 2022
c5b0a7b
Uses svg icons instead of icons-material ones
MBilalShafi Nov 2, 2022
0342f8d
Generates proptypes
MBilalShafi Nov 2, 2022
756d2d4
Updates method name and a few changes
MBilalShafi Nov 2, 2022
e9e5b54
Updates types, docs and other refactorings
MBilalShafi Nov 3, 2022
1cfdcb1
Merge branch 'next' into 4929-improve-column-menu
MBilalShafi Nov 3, 2022
376dfab
Moves icons and components in appropriate packages
MBilalShafi Nov 3, 2022
3ccd35d
Some remaining adjustments to differ Community, Pro and Premium compo…
MBilalShafi Nov 3, 2022
a796fe6
Apply suggestions from code review
MBilalShafi Nov 5, 2022
9aeb360
Resolves code comments and refactors
MBilalShafi Nov 5, 2022
2f4a246
Separates locales for two themes
MBilalShafi Nov 5, 2022
150f774
Updates locales
MBilalShafi Nov 5, 2022
59bdca8
Adds remaining locale variables
MBilalShafi Nov 5, 2022
eb8110e
Fixes a typo and types
MBilalShafi Nov 5, 2022
8309e84
Updates docs and resolves comments
MBilalShafi Nov 7, 2022
b4d4270
Fixes types
MBilalShafi Nov 7, 2022
7827a64
Resolves some comments and refactors a few codeblocks
MBilalShafi Nov 8, 2022
ab86e22
Merge branch 'next' into 4929-improve-column-menu
MBilalShafi Nov 9, 2022
6b07bd6
Merge branch 'next' into 4929-improve-column-menu
MBilalShafi Nov 10, 2022
e6608ff
Does refactoring as per discussion
MBilalShafi Nov 13, 2022
a040816
Some housekeeping
MBilalShafi Nov 13, 2022
15c7d76
Merge branch 'next' into 4929-improve-column-menu
MBilalShafi Nov 13, 2022
886268f
Removes types in .js file
MBilalShafi Nov 13, 2022
de4f04c
Runs docs:typescript
MBilalShafi Nov 13, 2022
559c7de
Refactors multiple things
MBilalShafi Nov 13, 2022
d3e1858
Some housekeeping work
MBilalShafi Nov 13, 2022
a2e8086
Updates proptypes
MBilalShafi Nov 13, 2022
5d5d302
Some renaming of variables
MBilalShafi Nov 14, 2022
9e65ef7
Fixes tests
MBilalShafi Nov 14, 2022
7afc688
Improvements
MBilalShafi Nov 15, 2022
4e30d39
Updates migration guide
MBilalShafi Nov 15, 2022
08208d7
Updates
MBilalShafi Nov 15, 2022
cabe8b7
Updates order of simple column menu items
MBilalShafi Nov 15, 2022
0bbd145
Moves rendering logic to pipe processors, adds a hook and some refact…
MBilalShafi Nov 16, 2022
ee05ffc
Merge 'next' into column menu
MBilalShafi Nov 17, 2022
c90f121
Updates documentation
MBilalShafi Nov 18, 2022
32ce867
Update docs/data/data-grid/column-menu/column-menu.md
MBilalShafi Nov 22, 2022
3224311
Adds some docs and some refactoring
MBilalShafi Nov 23, 2022
df6f0d6
Merge 'next' latest changes
MBilalShafi Nov 23, 2022
1bde428
Updates demo
MBilalShafi Nov 23, 2022
bf835a7
Adds support for slots and slotsProps in columnMenu
MBilalShafi Nov 23, 2022
63668bf
Improves docs and other stuff
MBilalShafi Nov 24, 2022
f59b066
Converts slots to components
MBilalShafi Nov 24, 2022
38e4754
Resolves some comments
MBilalShafi Nov 24, 2022
ab2cdad
Allows adding new items, passing props, updates docs and other changes
MBilalShafi Nov 26, 2022
8b0021f
Removes trailing semi-colon
MBilalShafi Nov 26, 2022
741f09e
Applies vale' suggestion
MBilalShafi Nov 26, 2022
99f57f5
Apply suggestions from code review
MBilalShafi Nov 29, 2022
a7adc86
Resolves some comments
MBilalShafi Nov 29, 2022
191ae2b
Adds reference grid in docs
MBilalShafi Nov 30, 2022
07bd2e4
Remove 'customItems' prop and some docs improvements
MBilalShafi Nov 30, 2022
202464a
Resolves comment
MBilalShafi Nov 30, 2022
c90a705
Changes 'currentColumn' to 'colDef'
MBilalShafi Nov 30, 2022
a891280
Reverts removal of outdated locales
MBilalShafi Nov 30, 2022
e9cad45
Adds Generic component to abstract out internal props
MBilalShafi Nov 30, 2022
a7d3a61
Fixes tests
MBilalShafi Dec 1, 2022
36cbdc2
Generates docs
MBilalShafi Dec 1, 2022
41d4c95
Merge branch 'next' into 4929-improve-column-menu
MBilalShafi Dec 1, 2022
c40fcc7
Housekeeping
MBilalShafi Dec 1, 2022
6ab542e
Applies padding from outside
MBilalShafi Dec 1, 2022
6f8050c
Applies code review suggestions
MBilalShafi Dec 1, 2022
80465d4
Fixes #6963
MBilalShafi Dec 1, 2022
b91201f
Updates migration guide
MBilalShafi Dec 1, 2022
c93b673
Fixes typo
MBilalShafi Dec 1, 2022
e2e1b58
Revert "Fixes #6963"
MBilalShafi Dec 2, 2022
2193906
Reverts migration guide change
MBilalShafi Dec 2, 2022
23216b8
Apply suggestions from code review
MBilalShafi Dec 2, 2022
bbfa25c
Resolves comments
MBilalShafi Dec 2, 2022
3f13481
Apply suggestions from code review
MBilalShafi Dec 2, 2022
72504e4
Pushes 'Disable column menu' to the last
MBilalShafi Dec 2, 2022
4b832ce
Updates docs a bit
MBilalShafi Dec 4, 2022
8d7c112
Applies suggestion
MBilalShafi Dec 5, 2022
f9f76e9
Updates docs
MBilalShafi Dec 5, 2022
c3a15e2
Updates 'components' -> 'items' in table heading
MBilalShafi Dec 6, 2022
6c56fae
Updates default 'displayOrder'
MBilalShafi Dec 6, 2022
1ea8c4e
Fixes #7103
MBilalShafi Dec 6, 2022
b7e58a0
Fixes cross button alignment
MBilalShafi Dec 7, 2022
88be3b1
Accomodates proposed design changes
MBilalShafi Dec 14, 2022
ebd7956
Some housekeeping
MBilalShafi Dec 15, 2022
671b753
Merge 'next' into '4929-improve-column-menu'
MBilalShafi Dec 15, 2022
60300f3
Fix accessibility and other visual updates
MBilalShafi Dec 15, 2022
0838333
Fix build
MBilalShafi Dec 15, 2022
0d6d3fb
Removes unused l10n labels
MBilalShafi Dec 15, 2022
d8373fa
Introduce 'MenuListProps' prop
MBilalShafi Dec 15, 2022
a490e28
Minor fix
MBilalShafi Dec 15, 2022
e1e5938
Add svg icon
MBilalShafi Dec 15, 2022
a542047
update tests
MBilalShafi Dec 15, 2022
05a466d
Merge 'next' into '4929-improve-column-menu'
MBilalShafi Dec 19, 2022
9d61d3f
Groups hide and manage and updates premium demo
MBilalShafi Dec 19, 2022
d72cb32
Close menu on aggregation 'onChange'
MBilalShafi Dec 19, 2022
b590bef
Reverts argos change
MBilalShafi Dec 19, 2022
b7c5a84
Refactor
MBilalShafi Dec 19, 2022
f41d96d
Resolve conflicts
MBilalShafi Dec 20, 2022
665abb4
Fix cell header focus not working as expected
MBilalShafi Dec 21, 2022
408e0ac
Type casting to string
MBilalShafi Dec 21, 2022
ab198c3
Andrew's suggested solution for focus management
MBilalShafi Dec 21, 2022
180350f
Update solution to more concrete one
MBilalShafi Dec 21, 2022
ef0f50e
Resolves CR comments
MBilalShafi Dec 22, 2022
b0ab240
Update migration guide
MBilalShafi Dec 22, 2022
4f488b6
Resolves more comments
MBilalShafi Dec 22, 2022
c7201cc
l10n
MBilalShafi Dec 22, 2022
29b911a
More comments
MBilalShafi Dec 22, 2022
6ee73b7
Migration guide
MBilalShafi Dec 22, 2022
07c4472
Reverts unnecessary condition
MBilalShafi Dec 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
6 changes: 0 additions & 6 deletions docs/data/data-grid/column-header/column-header.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ const columns: GridColDef[] = [

You can check the [styling header](/x/react-data-grid/style/#styling-column-headers) section for more information.

## Column menu

By default, each column header displays a column menu. The column menu allows actions to be performed in the context of the target column, e.g. filtering. To disable the column menu, set the prop `disableColumnMenu={true}`.

{{"demo": "ColumnMenuGrid.js", "bg": "inline"}}

## API

- [DataGrid](/x/api/data-grid/data-grid/)
Expand Down
54 changes: 54 additions & 0 deletions docs/data/data-grid/column-menu/AddNewColumnMenuGrid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import * as React from 'react';
import MenuItem from '@mui/material/MenuItem';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import SettingsApplicationsIcon from '@mui/icons-material/SettingsApplications';
import { DataGrid, GridColumnMenu } from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';

function CustomUserItem(props) {
const { myCustomHandler, myCustomValue } = props;
return (
<MenuItem onClick={myCustomHandler}>
<ListItemIcon>
<SettingsApplicationsIcon fontSize="small" />
</ListItemIcon>
<ListItemText>{myCustomValue}</ListItemText>
</MenuItem>
);
}

function CustomColumnMenu(props) {
return (
<GridColumnMenu
{...props}
components={{
// Add new item
ColumnMenuUserItem: CustomUserItem,
}}
componentsProps={{
columnMenuUserItem: {
// set `displayOrder` for new item
displayOrder: 15,
// pass additional props
myCustomValue: 'Do custom action',
myCustomHandler: () => alert('Custom handler fired'),
},
}}
/>
);
}

export default function AddNewColumnMenuGrid() {
const { data } = useDemoData({
dataSet: 'Commodity',
rowLength: 20,
maxColumns: 5,
});

return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid {...data} components={{ ColumnMenu: CustomColumnMenu }} />
</div>
);
}
59 changes: 59 additions & 0 deletions docs/data/data-grid/column-menu/AddNewColumnMenuGrid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import * as React from 'react';
import MenuItem from '@mui/material/MenuItem';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import SettingsApplicationsIcon from '@mui/icons-material/SettingsApplications';
import {
DataGrid,
GridColumnMenu,
GridColumnMenuProps,
GridColumnMenuItemProps,
} from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';

function CustomUserItem(props: GridColumnMenuItemProps) {
const { myCustomHandler, myCustomValue } = props;
return (
<MenuItem onClick={myCustomHandler}>
<ListItemIcon>
<SettingsApplicationsIcon fontSize="small" />
</ListItemIcon>
<ListItemText>{myCustomValue}</ListItemText>
</MenuItem>
);
}

function CustomColumnMenu(props: GridColumnMenuProps) {
return (
<GridColumnMenu
{...props}
components={{
// Add new item
ColumnMenuUserItem: CustomUserItem,
}}
componentsProps={{
columnMenuUserItem: {
// set `displayOrder` for new item
displayOrder: 15,
// pass additional props
myCustomValue: 'Do custom action',
myCustomHandler: () => alert('Custom handler fired'),
},
}}
/>
);
}

export default function AddNewColumnMenuGrid() {
const { data } = useDemoData({
dataSet: 'Commodity',
rowLength: 20,
maxColumns: 5,
});

return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid {...data} components={{ ColumnMenu: CustomColumnMenu }} />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<DataGrid {...data} components={{ ColumnMenu: CustomColumnMenu }} />
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function ColumnMenuGrid() {

return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid {...data} disableColumnMenu />
<DataGrid {...data} />
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function ColumnMenuGrid() {

return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid {...data} disableColumnMenu />
<DataGrid {...data} />
cherniavskii marked this conversation as resolved.
Show resolved Hide resolved
</div>
);
}
1 change: 1 addition & 0 deletions docs/data/data-grid/column-menu/ColumnMenuGrid.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<DataGrid {...data} />
45 changes: 45 additions & 0 deletions docs/data/data-grid/column-menu/ColumnMenuGridPremium.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as React from 'react';
import {
DataGridPremium,
useGridApiRef,
useKeepGroupedColumnsHidden,
} from '@mui/x-data-grid-premium';
import { useMovieData } from '@mui/x-data-grid-generator';

export default function ColumnMenuGridPremium() {
const apiRef = useGridApiRef();
const data = useMovieData();

const initialState = useKeepGroupedColumnsHidden({
apiRef,
initialState: {
aggregation: {
model: {
gross: 'avg',
},
},
columns: {
columnVisibilityModel: {
cinematicUniverse: false,
title: false,
},
},
rowGrouping: {
model: ['company'],
},
},
});

return (
<div style={{ height: 400, width: '100%' }}>
<DataGridPremium
{...data}
apiRef={apiRef}
groupingColDef={{
leafField: 'title',
}}
initialState={initialState}
/>
</div>
);
}
45 changes: 45 additions & 0 deletions docs/data/data-grid/column-menu/ColumnMenuGridPremium.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as React from 'react';
import {
DataGridPremium,
useGridApiRef,
useKeepGroupedColumnsHidden,
} from '@mui/x-data-grid-premium';
import { useMovieData } from '@mui/x-data-grid-generator';

export default function ColumnMenuGridPremium() {
const apiRef = useGridApiRef();
const data = useMovieData();

const initialState = useKeepGroupedColumnsHidden({
apiRef,
initialState: {
aggregation: {
model: {
gross: 'avg',
},
},
columns: {
columnVisibilityModel: {
cinematicUniverse: false,
title: false,
},
},
rowGrouping: {
model: ['company'],
},
},
});

return (
<div style={{ height: 400, width: '100%' }}>
<DataGridPremium
{...data}
apiRef={apiRef}
groupingColDef={{
leafField: 'title',
}}
initialState={initialState}
/>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<DataGridPremium
{...data}
apiRef={apiRef}
groupingColDef={{
leafField: 'title',
}}
initialState={initialState}
/>
Loading