Skip to content

Commit

Permalink
Added: "All" option to "rows per page" in TablePagination API
Browse files Browse the repository at this point in the history
[fixed] page range display for 'all' option

[fixed]The page range display showed 1--1 of {totalRows} when the option to display all the rows was chosen.
  • Loading branch information
eps1lon authored and SarthakC committed Oct 17, 2019
1 parent 5d564f9 commit 4bc35bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,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
7 changes: 4 additions & 3 deletions packages/material-ui/src/TablePagination/TablePagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export const styles = theme => ({
},
});

const defaultLabelDisplayedRows = ({ from, to, count }) => `${from}-${to} of ${count}`;
const defaultLabelDisplayedRows = ({ from, to, count }) =>
`${from}-${to === -1 ? count : to} of ${count}`;
const defaultRowsPerPageOptions = [10, 25, 50, 100];

/**
Expand Down Expand Up @@ -125,9 +126,9 @@ const TablePagination = React.forwardRef(function TablePagination(props, ref) {
<MenuItemComponent
className={classes.menuItem}
key={rowsPerPageOption}
value={rowsPerPageOption}
value={rowsPerPageOption.value ? rowsPerPageOption.value : rowsPerPageOption}
>
{rowsPerPageOption}
{rowsPerPageOption.label ? rowsPerPageOption.label : rowsPerPageOption}
</MenuItemComponent>
))}
</Select>
Expand Down

0 comments on commit 4bc35bf

Please sign in to comment.