I have table made with MUI. Problem: I can’t make all the header to be sticky. It only makes sticky
雇用形態, 応募経路 and months cells. But “FY23” is completely ignored and always hidden when scrolling. Can it be fixed?
`const ScrollableTable = ({ data }) => {
const counts = processData(data);
const isSmallScreen = useMediaQuery(‘(max-width: 1366px)’);
<code>return (
<TableContainer component={Paper} style={{ maxHeight: 500 }}>
<Table stickyHeader aria-label="sticky table" style={{ minWidth: isSmallScreen ? 650 : '100%' }}>
<TableHead>
<StyledTableRow>
<StyledTableCell colSpan={14} align="center" style={{ backgroundColor: '#3c3e42', color: 'white', fontWeight: 'bold', fontSize: '1.2rem' }}>
内定者一覧
</StyledTableCell>
</StyledTableRow>
<StyledTableRow>
<StyledTableCell rowSpan={3} align="center">雇用形態</StyledTableCell>
<StyledTableCell rowSpan={3} align="center">応募経路</StyledTableCell>
<StyledTableCell colSpan={12} align="center" aria-label="sticky table">FY23</StyledTableCell>
</StyledTableRow>
<StyledTableRow>
{japaneseMonths.map(month => (
<StyledTableCell key={`month-${month}`}>{month}</StyledTableCell>
))}
</StyledTableRow>
</TableHead>
<TableBody>
{Object.keys(counts).map((category) => (
<React.Fragment key={`category-${category}`}>
<StyledTableRow key={`category-row-${category}`}>
<StyledTableCell rowSpan={10} align="center">{category}</StyledTableCell>
<StyledTableCell>{'全体数'}</StyledTableCell>
{counts[category]['全体数'].map((count, idx) => (
<StyledTableCell key={`total-${category}-${idx}`}>{count}</StyledTableCell>
))}
</StyledTableRow>
{Object.keys(counts[category]).filter(route => route !== '全体数').map((route) => (
<StyledTableRow
key={`route-${category}-${route}`}
sx={{ backgroundColor: route === '入社確定' ? '#fabf34' : 'inherit' }}
>
<StyledTableCell>{route}</StyledTableCell>
{counts[category][route].map((count, idx) => (
<StyledTableCell key={`route-count-${category}-${route}-${idx}`}>{count}</StyledTableCell>
))}
</StyledTableRow>
))}
</React.Fragment>
))}
</TableBody>
</Table>
</TableContainer>
);
</code>
<code>return (
<TableContainer component={Paper} style={{ maxHeight: 500 }}>
<Table stickyHeader aria-label="sticky table" style={{ minWidth: isSmallScreen ? 650 : '100%' }}>
<TableHead>
<StyledTableRow>
<StyledTableCell colSpan={14} align="center" style={{ backgroundColor: '#3c3e42', color: 'white', fontWeight: 'bold', fontSize: '1.2rem' }}>
内定者一覧
</StyledTableCell>
</StyledTableRow>
<StyledTableRow>
<StyledTableCell rowSpan={3} align="center">雇用形態</StyledTableCell>
<StyledTableCell rowSpan={3} align="center">応募経路</StyledTableCell>
<StyledTableCell colSpan={12} align="center" aria-label="sticky table">FY23</StyledTableCell>
</StyledTableRow>
<StyledTableRow>
{japaneseMonths.map(month => (
<StyledTableCell key={`month-${month}`}>{month}</StyledTableCell>
))}
</StyledTableRow>
</TableHead>
<TableBody>
{Object.keys(counts).map((category) => (
<React.Fragment key={`category-${category}`}>
<StyledTableRow key={`category-row-${category}`}>
<StyledTableCell rowSpan={10} align="center">{category}</StyledTableCell>
<StyledTableCell>{'全体数'}</StyledTableCell>
{counts[category]['全体数'].map((count, idx) => (
<StyledTableCell key={`total-${category}-${idx}`}>{count}</StyledTableCell>
))}
</StyledTableRow>
{Object.keys(counts[category]).filter(route => route !== '全体数').map((route) => (
<StyledTableRow
key={`route-${category}-${route}`}
sx={{ backgroundColor: route === '入社確定' ? '#fabf34' : 'inherit' }}
>
<StyledTableCell>{route}</StyledTableCell>
{counts[category][route].map((count, idx) => (
<StyledTableCell key={`route-count-${category}-${route}-${idx}`}>{count}</StyledTableCell>
))}
</StyledTableRow>
))}
</React.Fragment>
))}
</TableBody>
</Table>
</TableContainer>
);
</code>
return (
<TableContainer component={Paper} style={{ maxHeight: 500 }}>
<Table stickyHeader aria-label="sticky table" style={{ minWidth: isSmallScreen ? 650 : '100%' }}>
<TableHead>
<StyledTableRow>
<StyledTableCell colSpan={14} align="center" style={{ backgroundColor: '#3c3e42', color: 'white', fontWeight: 'bold', fontSize: '1.2rem' }}>
内定者一覧
</StyledTableCell>
</StyledTableRow>
<StyledTableRow>
<StyledTableCell rowSpan={3} align="center">雇用形態</StyledTableCell>
<StyledTableCell rowSpan={3} align="center">応募経路</StyledTableCell>
<StyledTableCell colSpan={12} align="center" aria-label="sticky table">FY23</StyledTableCell>
</StyledTableRow>
<StyledTableRow>
{japaneseMonths.map(month => (
<StyledTableCell key={`month-${month}`}>{month}</StyledTableCell>
))}
</StyledTableRow>
</TableHead>
<TableBody>
{Object.keys(counts).map((category) => (
<React.Fragment key={`category-${category}`}>
<StyledTableRow key={`category-row-${category}`}>
<StyledTableCell rowSpan={10} align="center">{category}</StyledTableCell>
<StyledTableCell>{'全体数'}</StyledTableCell>
{counts[category]['全体数'].map((count, idx) => (
<StyledTableCell key={`total-${category}-${idx}`}>{count}</StyledTableCell>
))}
</StyledTableRow>
{Object.keys(counts[category]).filter(route => route !== '全体数').map((route) => (
<StyledTableRow
key={`route-${category}-${route}`}
sx={{ backgroundColor: route === '入社確定' ? '#fabf34' : 'inherit' }}
>
<StyledTableCell>{route}</StyledTableCell>
{counts[category][route].map((count, idx) => (
<StyledTableCell key={`route-count-${category}-${route}-${idx}`}>{count}</StyledTableCell>
))}
</StyledTableRow>
))}
</React.Fragment>
))}
</TableBody>
</Table>
</TableContainer>
);
};`
I did not found anything in documentation about it. Nor anything in the Internet.