Skip to content

Commit

Permalink
handle TypeScript side
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Oct 18, 2019
1 parent b002e82 commit 9630eea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default function CustomPaginationActionsTable() {
<TableFooter>
<TableRow>
<TablePagination
rowsPerPageOptions={[5, 10, 25]}
rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]}
colSpan={3}
count={rows.length}
rowsPerPage={rowsPerPage}
Expand Down
21 changes: 17 additions & 4 deletions docs/src/pages/components/tables/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,26 @@ Here is an example of customizing the component. You can learn more about this i

{{"demo": "pages/components/tables/CustomizedTables.js"}}

## Custom Table Pagination Action
### Custom pagination options

The `Action` property of the `TablePagination` component allows the implementation of
custom actions.
It's possible to customise the options shown in the "Rows per page" select using the `rowsPerPageOptions` prop.
You should either provide an array of:

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

```jsx
<TablePagination rowsPerPageOptions={[10, 50]} />
```
- **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').

Custom options in the `Rows per page:` menu can be shown by using a JS object with the `label` key denoting the display string, such as `"All"`, and the `value` key defining the number of rows to be shown. The following example demonstrates the same.
```jsx
<TablePagination rowsPerPageOptions={[10, 50, { value: -1, label: 'All' }]} />
```

### Custom pagination actions

The `Action` property of the `TablePagination` component allows the implementation of
custom actions.

{{"demo": "pages/components/tables/CustomPaginationActionsTable.js"}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface TablePaginationTypeMap<P, D extends React.ElementType> {
onChangeRowsPerPage?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
page: number;
rowsPerPage: number;
rowsPerPageOptions?: number[];
rowsPerPageOptions?: (number | { value: number; label: string })[];
SelectProps?: Partial<SelectProps>;
};
defaultComponent: D;
Expand Down

0 comments on commit 9630eea

Please sign in to comment.