-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Table] Allow multiple header rows (Group) #17909
Comments
What about? import React from 'react';
import { makeStyles } from '@mui/material/styles';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
const useStyles = makeStyles({
root: {
width: '100%',
overflowX: 'auto',
},
table: {
minWidth: 650,
},
});
function createData(name: string, calories: number, fat: number, carbs: number, protein: number) {
return { name, calories, fat, carbs, protein };
}
const rows = [
createData('Frozen yoghurt', 159, 6.0, 24, 4.0),
createData('Ice cream sandwich', 237, 9.0, 37, 4.3),
createData('Eclair', 262, 16.0, 24, 6.0),
createData('Cupcake', 305, 3.7, 67, 4.3),
createData('Gingerbread', 356, 16.0, 49, 3.9),
];
export default function SimpleTable() {
const classes = useStyles();
return (
<Paper className={classes.root}>
<Table className={classes.table} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell />
<TableCell align="center" colSpan={2}>
Data 1
</TableCell>
<TableCell align="center" colSpan={2}>
Data 2
</TableCell>
</TableRow>
<TableRow>
<TableCell>Dessert (100g serving)</TableCell>
<TableCell align="right">Calories</TableCell>
<TableCell align="right">Fat (g)</TableCell>
<TableCell align="right">Carbs (g)</TableCell>
<TableCell align="right">Protein (g)</TableCell>
</TableRow>
</TableHead>
<TableBody>
{rows.map(row => (
<TableRow key={row.name}>
<TableCell component="th" scope="row">
{row.name}
</TableCell>
<TableCell align="right">{row.calories}</TableCell>
<TableCell align="right">{row.fat}</TableCell>
<TableCell align="right">{row.carbs}</TableCell>
<TableCell align="right">{row.protein}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Paper>
);
} |
This can work. Didn't know you can put two Thanks! Also I think this have to be part of the docs |
Agree, it's something to document, and potentially to improve the UI. |
I finally found the solution, It was that tiny pixel...
|
Can I add a new demo with multiple Table header rows, if that's okay? @oliviertassinari |
Hello! Is anyone working on this? This is my first contribution and would like to give this a shot. |
Note that we have a higher level API in the pipeline for column grouping: mui/mui-x#195. |
It would be great if you could add possibility to have multiple header rows
Summary 💡
The output table should have multiple header rows, it should look something like this:
Motivation 🔦
I need this to see how an item behaved in time
The text was updated successfully, but these errors were encountered: