Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data-grid] First/Last Page Icon Button #4249

Closed
2 tasks done
iEquos opened this issue Mar 21, 2022 · 7 comments
Closed
2 tasks done

[data-grid] First/Last Page Icon Button #4249

iEquos opened this issue Mar 21, 2022 · 7 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! design This is about UI or UX design, please involve a designer feature: Pagination Related to the data grid Pagination feature support: commercial Support request from paid users

Comments

@iEquos
Copy link

iEquos commented Mar 21, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Summary 馃挕

Is it possible to to include an optional first/last page button for the DataGridPro Lists.

This was possible when using Table and TablePagination Components (which we no longer use anymore as we have upgraded to the latest versionDataGridPro)

We used to have
<TablePagination
hidden={isSeraching}
rowsPerPageOptions={[5, 10, 15, 25, 50]}
component="div"
count={initList.length}
rowsPerPage={rowsPerPage}
page={page}
onPageChange={(e, newPage) => setPage(newPage)}
onRowsPerPageChange={(e) => handleChangeRowsPerPage(e.target.value)}
ActionsComponent={TablePaginationActions}
/>

Where TablePaginationActions component is:

import { Box, IconButton } from '@material-ui/core'
import FirstPageIcon from '@mui/icons-material/FirstPage'
import KeyboardArrowLeft from '@mui/icons-material/KeyboardArrowLeft'
import KeyboardArrowRight from '@mui/icons-material/KeyboardArrowRight'
import LastPageIcon from '@mui/icons-material/LastPage'
import { TablePaginationActionsProps } from '@material-ui/core/TablePagination/TablePaginationActions'
import React from 'react'

const TablePaginationActions: React.FC = (muiProps) => {
const { count, page, rowsPerPage, onPageChange } = muiProps

const handleFirstPageButtonClick = (event: React.MouseEvent) => {
event && onPageChange(event, 0)
}

const handleBackButtonClick = (event: React.MouseEvent) => {
onPageChange(event, page - 1)
}

const handleNextButtonClick = (event: React.MouseEvent) => {
onPageChange(event, page + 1)
}

const handleLastPageButtonClick = (event: React.MouseEvent) => {
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1))
}

return (
<Box sx={{ flexShrink: 0, ml: 2.5 }}>
<IconButton
onClick={handleFirstPageButtonClick}
disabled={page === 0}
aria-label="first page"
>


<IconButton
onClick={handleBackButtonClick}
disabled={page === 0}
aria-label="previous page"
>


= Math.ceil(count / rowsPerPage) - 1}
aria-label="next page"
>


= Math.ceil(count / rowsPerPage) - 1}
aria-label="last page"
>



)
}
export default TablePaginationActions

This worked and rendered out
image

Is it possible to get this with the DataGridPro? If not is this a feature you could add in?

Examples 馃寛

No response

Motivation 馃敠

Motivation: To have a first/last icon on our lists

Order ID 馃挸 (optional)

#37406

@iEquos iEquos added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 21, 2022
@m4theushw
Copy link
Member

Is it possible to get this with the DataGridPro?

Yes, you can override the pagination component. I think you can just reuse the old TablePagination you had without bigger changes. Check https://mui.com/components/data-grid/components/#pagination

@m4theushw m4theushw added support: commercial Support request from paid users component: data grid This is the name of the generic UI component, not the React module! feature: Pagination Related to the data grid Pagination feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 21, 2022
@m4theushw m4theushw changed the title First/Last Page Icon Button [DataGrid] First/Last Page Icon Button Mar 21, 2022
@iEquos
Copy link
Author

iEquos commented Mar 22, 2022

Thankyou for the reply.
We would quite like to update our lists to use the Pagination component that you linked to.
(this one: import Pagination from '@mui/material/Pagination')

Although the Pagination component seems to ignore the rowsPerPageOptions/pageSize props on out DataGridPro Component. And there's no example on the link you shared (https://mui.com/components/data-grid/components/#pagination) that shows how we could get a rows per page selector with the Pagination component.

So is it possible to get this:
image
but also have some sort of page size change functionality like this:
image

@iEquos iEquos mentioned this issue Mar 24, 2022
2 tasks
@m4theushw
Copy link
Member

The Pagination component doesn't have a rows per page selector. However, you can combine it with a Select. You can take as example the built-in pagination component we use: https://github.com/mui/mui-x/blob/master/packages/grid/x-data-grid/src/components/GridPagination.tsx

@flaviendelangle flaviendelangle changed the title [DataGrid] First/Last Page Icon Button [data-grid] First/Last Page Icon Button Mar 29, 2022
@flaviendelangle
Copy link
Member

I made a quick example with our default GridPagination combined with the custom actions from first and last page

which we no longer use anymore as we have upgraded to the latest versionDataGridPro

What is preventing you to use it ?

@flaviendelangle
Copy link
Member

I'm closing this one due to a lack of feedbacks

@pavankjadda
Copy link

I made a quick example with our default GridPagination combined with the custom actions from first and last page

which we no longer use anymore as we have upgraded to the latest versionDataGridPro

What is preventing you to use it ?

I like this. Shouldn't this be part of the DataGrid component? Because every table needs it.

@oliviertassinari oliviertassinari added design This is about UI or UX design, please involve a designer and removed design: ux labels Aug 18, 2023
@designly1
Copy link

I made a quick example with our default GridPagination combined with the custom actions from first and last page

which we no longer use anymore as we have upgraded to the latest versionDataGridPro

What is preventing you to use it ?

You saved my life! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! design This is about UI or UX design, please involve a designer feature: Pagination Related to the data grid Pagination feature support: commercial Support request from paid users
Projects
None yet
Development

No branches or pull requests

7 participants