-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[data grid] Context menu in column headers #12749
Comments
Hi @trbagley-gresham const onContextMenu = React.useCallback((event: React.MouseEvent) => {
const headerCell = (event.target as HTMLElement).closest(`[role="columnheader"]`);
if (!headerCell) {
return;
}
const field = headerCell.getAttribute('data-field');
console.log('Context menu on column header:', field);
}, []);
// ...
<DataGrid
rows={rows}
columns={columns}
slotProps={{
columnHeaders: {
onContextMenu,
},
}}
/> But it doesn't work because of a bug on our side – we don't pass the
Fortunately, you can override the Is this what you're looking for |
@cherniavskii thanks for the demo, this looks promising. I did try adding an We'll need to obtain the |
|
@cherniavskii perfect, thanks! |
@trbagley-gresham: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
Summary
Enhanced API for grid header customisation.
Examples
Related issue:
#6691
Motivation
We'd like to show the context menu when right clicking on a column header rather than clicking on the menu icon (three vertical dots). This would involve adding an
onContextMenu
event handler to each header which would open the filter panel. A frequent recommendation is to make use of therenderHeader
property ofGridColDef
; however, this does not give full control over the header as illustrated in the screenshot below:If we add an event handler via
renderHeader
, only the coloured sections are clickable as opposed to the entire header.Are there currently any props which would facilitate this? The closest implementation I have encountered can be seen in the MUI docs. If something similar to this is/was available for the header, I think it would address our requirements.
Search keywords: grid header customisation
Order ID: 45466
The text was updated successfully, but these errors were encountered: