'How to export all the pages to CSV in MUI DataGrid?

I hava a DataGrid table from Material UI with more than 3000 rows, each page contains max 50 rows per page.

What I want is to be able to export all the rows to CSV when I click the export btn.

Actual behavior: Only current page data is being exported

Can anybody give me a hint on what I am doing wrong ?

My code :

 <DataGrid
   rows={users}
   columns={columns}
   pageSize={limit}
   page={page - 1}
   rowCount={rowsCount}
  //rowsPerPageOptions={[limit]}
  pagination
  paginationMode="server"
  components={{
    Toolbar: GridToolbar,
  }}
  onPageChange={(data) => {
   updateUsers(data + 1, formSubmitted);
  }}
/>

DataGrid in the web example : Screensot of DataGrid Table



Sources

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

Source: Stack Overflow

Solution Source