How do I create multiple headers with column span in Material-UI DataGrid? enter image description here
-
Please provide enough code so others can better understand or reproduce the problem.Community– Community Bot2022-06-11 06:03:43 +00:00Commented Jun 11, 2022 at 6:03
-
I think what you want is something like this but for DataGrid, no? codesandbox.io/s/material-demo-r1p51?file=/demo.jsndtreviv– ndtreviv2022-11-24 09:38:58 +00:00Commented Nov 24, 2022 at 9:38
-
See here for a preview of the feature: deploy-preview-5133--material-ui-x.netlify.app/x/… being tracked by this GitHub issue: github.com/mui/mui-x/issues/295ndtreviv– ndtreviv2022-11-24 09:41:08 +00:00Commented Nov 24, 2022 at 9:41
-
Actually, it's been released. I think this is what you want: mui.com/x/react-data-grid/column-groupsndtreviv– ndtreviv2022-11-24 09:44:12 +00:00Commented Nov 24, 2022 at 9:44
Add a comment
|
1 Answer
You can use a custom toolbar to achieve your goal. Here's the documentation on how to
Example
const CustomToolbar = (props) => <h1>I'm a custom toolbar</h1>;
export default function ToolbarGrid() {
const { data } = useDemoData({
dataSet: "Commodity",
rowLength: 100,
maxColumns: 6
});
return (
<div style={{ height: 400, width: "100%" }}>
<DataGrid
{...data}
components={{
Toolbar: CustomToolbar
}}
/>
</div>
);
}
1 Comment
ndtreviv
This just creates a toolbar, it doesn't add another header row to the table.