'react mui-datatables, can't export only selected rows

I'm using "mui-datatables": "^4.2.2",

I wonder if this library is customizable enough to work with, because currently I just want to export the rows of tables that are selected.

enter image description here

I used the default download button of the library and also I added a custom button to allow the download of only selected table rows

const options = {
    ...  // other options
     onDownload: (buildHead, buildBody, columns, rows) => {
      console.log(rows); //  <-------- can't get only selected rows
    },
    customToolbarSelect: (selectedRows, displayData, setSelectedRows) => {
      return (
        <Box mr={4}>
          <Fab
            variant="extended"
            size="small"
            color="primary"
            aria-label="add"
            onClick={() => console.log(displayData)} // <--- can't get selected rows
          >
            <FileDownloadRounded />
            Exporter
          </Fab>
        </Box>
      );
    },

}

I used a customToolbarSelect and i tried to customize onDownload but i can't get only selected rows.

How can i correctly download only selected rows ?

Thank you !



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source