Search code examples
reactjsmaterial-uimui-datatablemui-x-data-grid

one click MUI export


Hello MUI datagrid react folks, I have disabled both csv and print since I only need excel. Now only excel shows but requires 2 clicks to export. One click for drop down to show then select export excel. How to make it export to excel on one click no show drop down. Thanks

I have this <GridToolbarExport printOptions={{ disableToolbarButton: true }} csvOptions={{ disableToolbarButton: true }}/>

enter image description here


Solution

  • You are trying to use the existing GridToolbar that renders as a drop-down with up to 3 sub-menu items to render. Disabling 2 of them still leaves the Excel sub-menu item to render, thus it takes 2 clicks to enable.

    You could instead create a custom toolbar with a single button that directly invokes the Export To Excel API.