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

[docs] Improve data grid pageSizeOptions prop documentation #11682

Merged
merged 4 commits into from
Jan 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions docs/data/data-grid/pagination/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ By default, each page contains 100 rows. The user can change the size of the pag

### Page size options

You can configure the page size the user can choose from with the `pageSizeOptions` prop.
Copy link
Member Author

Choose a reason for hiding this comment

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

The first two sentences says the same thing.

You can customize the options shown in the "Rows per page" select using the `pageSizeOptions` prop.
You should provide an array of items, each item should be one of these types:

It's possible to customize the options shown in the "Rows per page" select using the `pageSizeOptions` prop.
You should either provide an array of:
Copy link
Member Author

@oliviertassinari oliviertassinari Jan 14, 2024

Choose a reason for hiding this comment

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

This is wrong, it's not Array<number> | Array<object> but Array<number | object>.

- **number**, each number will be used for the option's label and value.

- **numbers**, each number will be used for the option's label and value.
```jsx
<DataGrid pageSizeOptions={[5, 10, 25]}>
```

- **objects**, the `value` and `label` keys will be used respectively for the value and label of the option (useful for language strings such as 'All').
Copy link
Member Author

Choose a reason for hiding this comment

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

useful for language strings such as 'All'

is false information.

  <DataGrid pageSizeOptions={[{ value: -1, label: 'All' }]}>

Doesn't work

Copy link
Member

Choose a reason for hiding this comment

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

Interesting. Should we support this use case anyways? I wonder if it'd be solved better by turning pagination off rather than supporting it with pageSizeOptions.

- **object**, the `value` and `label` keys will be used respectively for the value and label of the option.

```jsx
<DataGrid pageSizeOptions={[10, 100, { value: 1000, label: '1,000' }]}>
```

{{"demo": "PageSizeCustomOptions.js", "bg": "inline"}}

Expand All @@ -32,7 +38,7 @@ You can't use both the `autoPageSize` and `autoHeight` props at the same time be

{{"demo": "PageSizeAuto.js", "bg": "inline"}}

## Pagination on Pro and Premium
## Pagination on Pro and Premium [<span class="plan-pro"></span>](/x/introduction/licensing/#pro-plan 'Pro plan')[<span class="plan-premium"></span>](/x/introduction/licensing/#premium-plan 'Premium plan')

The default pagination behavior depends on your plan.

Expand Down