Material UI -Data Grid Custom Pagination - reactjs

I am trying to use the custom pagination from here
https://material-ui.com/components/data-grid/style/#custom-theme
however the pagination seems broken itself? Can anyone guide why the pagination is not working and what needs to be done, so that i can implement it?
When I click on page 2, and the click on Page 1, its not working.

I had to update the pagination to
<Pagination
color="primary"
showFirstButton
showLastButton
page={state.pagination.page + 1}
count={state.pagination.pageCount}
// #ts-expect-error
renderItem={props2 => <PaginationItem {...props2} disableRipple />}
onChange={(event, value) => apiRef.current.setPage(value-1)}
/>
)

Related

How to disable Material UI DataGrid go to next page button while loading the API

This code is regarding Material UI Datagrid
I need to disable the Go to next page button while loading the API
<DataGrid
autoHeight
getRowHeight={getRowHeight}
rows={rows}
columns={columns}
page={page - 1}
rowCount={total}
rowsPerPageOptions={rowsPerPage}
pagination
paginationMode='server'
pageSize={pageSize}
getRowClassName={(params) => getRowClassName(params)}
onPageChange={(newPage) => handelPageChange(newPage)}
loading={isLoading}
// disableNextPage={isLoading}
onPageSizeChange={(newPageSize) =>
setAssetList((prveState) => ({
...prveState,
pageSize: newPageSize,
}))
}
/>
I have used this prop it has been resolved
hideFooterPagination={isLoading}

How do I customize the MUI DataGrid footer components?

I am using the MUI V5 DataGrid component in my App and I want to customize the Footer component on the datagrid component but can't find any docs on how to go about it. This is the current default footer:
I want to achieve something resembling this:
Is there a way to reorganize the individual components and customize the styling as such? Any help is highly appreciated.
this sample code you can use for a custom footer in data grid MUI v5
first, you write your pagination component with full logic when the client clicked on the page, like this :
const RoundedPagination = () => {
return (
<Stack spacing={2}>
<Pagination
shape="rounded" page={page + 1} onChange={handleChange} count={props.numberOfPages}
renderItem={(item) => (
<PaginationItem
sx={{
color: 'main.0',
}}
components={{previous: ArrowRightRoundedIcon, next: ArrowLeftRoundedIcon}}
{...item}
/>
)}
/>
</Stack>
)
}
then you use this component in data grid like this :
<Grid container item justifyContent={'center'} alignItems={'center'} md={12}>
<DataGrid
page={page}
rows={props.dataGridValue.ROW}
columns={props.dataGridValue.COLUMNS}
autoHeight
headerHeight={52}
rowsPerPageOptions={[10]}
disableColumnMenu
Pagination
hideFooterSelectedRowCount
components={{
Pagination: RoundedPagination,
}}
/>
</Grid>
hope you get your answer good luck ;)

Pagination RTL next and previous arrowsheads are facing in the wrong direction material ui react

related to this issue
https://github.com/mui/material-ui/issues/20193
Pagination Arrow Working on reverse on RTL direction
From Mui Documentation:
Right-to-left languages such as Arabic, Persian, or Hebrew are supported. To change the direction of MUI components you must follow the following steps.
Documentation and Demo:
https://mui.com/material-ui/guides/right-to-left/#demo
Pagination in RTL Demo:
https://codesandbox.io/s/direction-material-demo-forked-zdgsi8?file=/demo.js
you can Change Arrow Icons like this:
The Previous Button change it to Forward Button and the Next Button Change it to Back Button :) Enjoy!! XD
reference For changing icons: https://mui.com/material-ui/react-pagination/#custom-icons
<Pagination
count={pageCount}
page={page}
onChange={(e, newPage: number) => setPage(newPage)}
renderItem={item => (
<PaginationItem
components={{ previous: ArrowForward, next: ArrowBack }}
{...item}
/>
)}
/>

How to add a custom Button in AntD pagination to download a report?

I want to add download button in pagination and I want to allow download table data as an excel file. Is it possible to add and render a custom button in Antd pagination. Here with I attached an image to show what I am going to archive.
You can use showTotal of Pagination props like below:
import { Pagination, Button } from "antd";
import DownloadOutlined from "#ant-design/icons/DownloadOutlined";
// render Pagination
<Pagination
total={25}
showSizeChanger
showTotal={(total) => (
<div>
{`Total ${total} items`}
<Button
type="primary"
icon={<DownloadOutlined />}
style={{ marginLeft: 8 }}
/>
</div>
)}
/>

How to close Filter dialog in MUI datatable

I am using MUI datatable in my react project. I used serverside filtering and customFilterDialogFooter where I include following code in options which is passed in mui-datatables. When I click on Apply Filters button, I fetched data from server using my filtering criteria which is completely fine but Filter window is not closed. Is there any way to close filter window?
customFilterDialogFooter: filterList => {
return (
<div style={{marginTop: '40px'}}>
<Button variant="contained" onClick={() => {
handleFilterSubmit(filterList)
}}>Apply Filters</Button>
</div>
);
}
Filter dialog is closed on the version mui-datatables": "3.0.0"
<MUIDataTable
data={data}
columns={COLUMNS}
options={{ viewColumns: false }}
/>

Resources