'Material-Table columns not resizable with more than 5 columns
I am displaying data using material-table. I have 19 columns to display and I want to set a fixed size for each column. Using width: 45% is not making any visual changes. I can't use whiteSpace: "nowrap" because that will only make the table longer and more difficult to use when some cells have large sentences. I have tried using width, cellStyle and headerStyle in all 19 of my columns but it made no difference.
Here are some of my columns and my table:
const columns = [
{ title: "Sizing ID", field: "SizingId" },
{ title: "Intake ID", field: "IntakeID" },
{ title: "FCRID", field: "FCRID" },
{ title: "Taxonomy ID", field: "TaxonomyId" },
{ title: "Domain", field: "Domain" },
{ title: "Experience", field: "Experience" },
{ title: "Product Line", field: "ProductLine" },
{ title: "Sizing Contact", field: "SizingContact" },
{ title: "Q1Cost", field: "Q1Cost" },
{ title: "Sizing Comments", field: "SizingComments" },
];
...
<MaterialTable
title="Sizing"
data={sizing.sizing}
columns={columns}
options={{
pageSize: 15,
pageSizeOptions: [15, 25, 50],
padding: "dense",
headerStyle: {
backgroundColor: "#0076CE",
color: "#e5e6e7",
fontFamily: "sans-serif",
fontSize: 12,
fontWeight: 600,
maxWidth: 200,
},
rowStyle: (data, index) => {
if (index % 2) {
return {
backgroundColor: "#EEEEEE",
fontSize: 12,
};
} else {
return { fontSize: 12 };
}
},
}}
/>
Solution 1:[1]
Just try to use Fixed columns with a large number of columns in the docs https://material-table.com/#/docs/features/fixed-columns
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Amr Viernes |
