How can I disable or remove the export PDF button option?? I didn't found it on the docs
I couldn't find anything to remove this either. This is a very temporary workaround because the users will wonder why they can't export to PDF and I think alerts are a no-no in React, but this is what I'm doing. In the options prop of MaterialTable, add
exportPdf: () => alert('This feature is disabled. Data can only be exported as a CSV.')
I am also looking for a solution to this issue on how to hide/remove "Export as PDF".
I'm also looking for solution
+1
+1
+1
I am also looking for a solution to this issue on how to hide/remove "Export as PDF".
and i think catch event for them ( like exportCSV event)
If you are desperate, as a temporary solution, you can select it with css, then change its display, here is the selector:
li.MuiButtonBase-root.MuiListItem-root.MuiMenuItem-root.MuiMenuItem-gutters.MuiListItem-gutters.MuiListItem-button:nth-child(2) {
display:none !important;
}
This is a slightly more robust workaround in plain JavaScript, using a MutationObserver to determine when the export menu opens and then removing the "Export as PDF" menu item:
setTimeout(() => { // Wait until page load.
new MutationObserver((mutations, observer) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((addedNode) => {
if (addedNode.nodeType === Node.ELEMENT_NODE) {
const element = addedNode;
if (element.classList.contains('MuiPopover-root')) {
Array.from(
element.getElementsByClassName('MuiMenuItem-root'),
).forEach((menuItem) => {
if (menuItem.textContent === 'Export as PDF') {
menuItem.remove();
}
});
}
}
});
});
}).observe(document.body, {childList: true});
}, 0);
This is fixed as of 1.6.9 via https://github.com/mbrn/material-table/pull/2335
So now you can opt in to only the csv button:
<MaterialTable options={{ exportButton: { csv: true }} />
This issue can be closed
Using 1.69.2 and the correct syntax to exclude the PDF option is:
<MaterialTable options={{ exportButton: { csv: true, pdf: false }} />
Most helpful comment
This is fixed as of 1.6.9 via https://github.com/mbrn/material-table/pull/2335
So now you can opt in to only the csv button: