我在我的反应应用程序中使用mui-datatable,我想在我的表格中添加一个水平滚动条以显示溢出列,而不是让表格伸展超过 Windows 屏幕宽度。
这是我的代码
const TableSection = (props) => {
const columns = [
{ name: "invoice_id", label: "Invoice No" },
{ name: "mode", label: "Mode" },
{ name: "date", label: "Date" },
{ name: "quantity", label: "Quantity" },
{ name: "status", label: "Status" },
{ name: "shipping_address_owner", label: "Customer" },
{
name: "product",
label: "Products",
options: {
customBodyRender: (value, tableMeta, updateValue) => (
<div>{value.join(",")}</div>
),
},
},
{
name: "payment_made",
label: "Amount paid",
options: {
customBodyRender: function (value, tableMeta, updateValue) {
return new Intl.NumberFormat().format(value); // comma separator
},
},
},
];
return (
<div className={classes.root}>
<Grid container spacing={3}>
<Grid item xs={12}>
<Paper className={classes.paper}>
<MUIDataTable
title={"Recent Purchases Invoice"}
data={invoiceData}
columns={columns}
options={options}
/>
</Paper>
</Grid>
</Grid>
</div>
);
};
export default TableSection;
const options = {
filterType: "checkbox",
rowsPerPage: 5,
rowsPerPageOptions: [5, 10, 15, 20],
downloadOptions: { filename: "InvoiceData.csv", separator: "," },
elevation: 6,
};
编辑:添加表选项值