From f747a5510b7c2cb273dd29dcde3e0e4077b8accc Mon Sep 17 00:00:00 2001 From: keisuke-umezawa Date: Tue, 11 Jun 2024 21:32:08 +0900 Subject: [PATCH] Restore initialRowsPerPage --- tslib/react/src/components/DataGrid.tsx | 15 ++++++++------- tslib/react/src/components/TrialTable.tsx | 11 +++++++++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tslib/react/src/components/DataGrid.tsx b/tslib/react/src/components/DataGrid.tsx index b268ee81..4462768b 100644 --- a/tslib/react/src/components/DataGrid.tsx +++ b/tslib/react/src/components/DataGrid.tsx @@ -119,17 +119,23 @@ function FilterMenu({ function DataGrid({ data, columns, + initialRowsPerPage, }: { data: T[] columns: ColumnDef[] + initialRowsPerPage?: number }): React.ReactElement { const [sorting, setSorting] = React.useState([]) const [columnFilters, setColumnFilters] = React.useState( [] ) + const rowsPerPageOptions = [10, 50, 100, { label: "All", value: data.length }] const [pagination, setPagination] = React.useState({ pageIndex: 0, - pageSize: 50, + pageSize: + initialRowsPerPage && rowsPerPageOptions.includes(initialRowsPerPage) + ? initialRowsPerPage + : 50, }) const table = useReactTable({ @@ -236,12 +242,7 @@ function DataGrid({ = ( export const TrialTable: FC<{ study: Optuna.Study -}> = ({ study }) => { + initialRowsPerPage?: number +}> = ({ study, initialRowsPerPage }) => { const trials: Optuna.Trial[] = study.trials const columnHelper = createColumnHelper() @@ -99,5 +100,11 @@ export const TrialTable: FC<{ } } - return + return ( + + ) }