Using the materialui-datatables package, is there a way to toggle the column headers? I see examples for overriding the custom styling but can't find an option in the site api.
Examples are here in a sandbox.
My current table looks like this:
const columns = [
{
name: "Question",
label: "",
options: {
someOptionToToggle: true
},
},
{
name: "Answer",
label: ""
}
];
const options = {
filter: false,
responsive: "scroll",
download: false,
sort: false,
selectableRows: false,
print: false,
viewColumns: false,
searchOpen: true,
searchText: searchText,
search: false,
customSearchRender: () => null
};
<MUIDataTable
title={""}
data={faqData}
columns={columns}
options={options}
/>
It would seem that the option label option would provide this if set to blank, but the header name remains.
I've tried various other attributes in the column options, is this possible?
As of now, with latest MUI version you can make use of the slots/slotsProps to customize the DataGrid.
The component/componentProps is now deprecated.
More information: https://mui.com/x/react-data-grid/components/#overriding-components
The slots props allows you to customize the column header where you can return null to hide it.
Example:
<DataGrid
slots={{
columnHeaders: () => null,
}}
/>
Use columnHeaderHeight https://mui.com/x/api/data-grid/data-grid/#DataGrid-prop-columnHeaderHeight
Example:
<DataGridPro
columnHeaderHeight={0}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With