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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Change page index base, from 1 to 0 #1021

Merged
merged 2 commits into from
Feb 10, 2021
Merged

Conversation

dtassone
Copy link
Member

@dtassone dtassone commented Feb 9, 2021

Breaking changes

  • [DataGrid] Change page index base, from 1 to 0. This change is done for consistency with TablePagination and JavaScript arrays that are 0-based. Material-UI still uses a 1-base page for the Pagination component that matches the URL's query.

    -const [page, setPage] = React.useState(1);
    +const [page, setPage] = React.useState(0);
    
    return (
      <div className="grid-container">
       <DataGrid rows={rows} columns={columns} page={page} />
      </div>

fix #852

@@ -130,9 +130,9 @@ export function PaginationApiTests() {
Pagination: ({ state }) => (
<Pagination
className="my-custom-pagination"
page={state.pagination.page}
page={state.pagination.page + 1}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need it here? Is it to load the second page?

Copy link
Member Author

@dtassone dtassone Feb 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it to load the second page?

No it's for the component. As it's 0 indexed, we need to add 1 to convert it to the page number from the index

@material-ui/lab/Pagination is 1-based.

@oliviertassinari oliviertassinari added breaking change component: data grid This is the name of the generic UI component, not the React module! labels Feb 10, 2021
@oliviertassinari oliviertassinari changed the title [DataGrid] fix page index to 0 [DataGrid] Change page index base, from 1 to 0 Feb 10, 2021
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] Pagination is 1-based but should be 0-based
3 participants