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

Fix/rows per page options #796

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions packages/material-react-table/src/toolbar/MRT_TablePagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
interface Props<TData extends MRT_RowData>
extends Partial<
PaginationProps & {
rowsPerPageOptions?: number[];
rowsPerPageOptions?: { label: string; value: number }[] | number[];
showRowsPerPage?: boolean;
}
> {
Expand Down Expand Up @@ -103,11 +103,17 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
value={pageSize}
variant="standard"
>
{rowsPerPageOptions.map((value) => (
<MenuItem key={value} sx={{ m: 0 }} value={value}>
{value}
</MenuItem>
))}
{rowsPerPageOptions.map((option) =>
typeof option === 'number' ? (
<MenuItem key={option} sx={{ m: 0 }} value={option}>
{option}
</MenuItem>
) : (
<MenuItem key={option.value} sx={{ m: 0 }} value={option.value}>
{option.label}
</MenuItem>
),
)}
</Select>
</Box>
)}
Expand Down
4 changes: 2 additions & 2 deletions packages/material-react-table/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -904,13 +904,13 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
muiPaginationProps?:
| ((props: { table: MRT_TableInstance<TData> }) => Partial<
PaginationProps & {
rowsPerPageOptions?: number[];
rowsPerPageOptions?: {label: string; value: number}[] | number[];
showRowsPerPage?: boolean;
}
>)
| Partial<
PaginationProps & {
rowsPerPageOptions?: number[];
rowsPerPageOptions?: {label: string; value: number;}[] | number[];
showRowsPerPage?: boolean;
}
>;
Expand Down