mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-11 12:30:25 +08:00
Restore initialRowsPerPage
This commit is contained in:
@@ -119,17 +119,23 @@ function FilterMenu<T>({
|
||||
function DataGrid<T>({
|
||||
data,
|
||||
columns,
|
||||
initialRowsPerPage,
|
||||
}: {
|
||||
data: T[]
|
||||
columns: ColumnDef<T>[]
|
||||
initialRowsPerPage?: number
|
||||
}): React.ReactElement {
|
||||
const [sorting, setSorting] = React.useState<SortingState>([])
|
||||
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
|
||||
[]
|
||||
)
|
||||
const rowsPerPageOptions = [10, 50, 100, { label: "All", value: data.length }]
|
||||
const [pagination, setPagination] = React.useState<PaginationState>({
|
||||
pageIndex: 0,
|
||||
pageSize: 50,
|
||||
pageSize:
|
||||
initialRowsPerPage && rowsPerPageOptions.includes(initialRowsPerPage)
|
||||
? initialRowsPerPage
|
||||
: 50,
|
||||
})
|
||||
|
||||
const table = useReactTable({
|
||||
@@ -236,12 +242,7 @@ function DataGrid<T>({
|
||||
</TableContainer>
|
||||
<Box component="div" display="flex" alignItems="center">
|
||||
<TablePagination
|
||||
rowsPerPageOptions={[
|
||||
10,
|
||||
50,
|
||||
100,
|
||||
{ label: "All", value: data.length },
|
||||
]}
|
||||
rowsPerPageOptions={rowsPerPageOptions}
|
||||
component="div"
|
||||
count={table.getFilteredRowModel().rows.length}
|
||||
rowsPerPage={table.getState().pagination.pageSize}
|
||||
|
||||
@@ -21,7 +21,8 @@ const multiValueFilter: FilterFn<Optuna.Trial> = <D extends object>(
|
||||
|
||||
export const TrialTable: FC<{
|
||||
study: Optuna.Study
|
||||
}> = ({ study }) => {
|
||||
initialRowsPerPage?: number
|
||||
}> = ({ study, initialRowsPerPage }) => {
|
||||
const trials: Optuna.Trial[] = study.trials
|
||||
|
||||
const columnHelper = createColumnHelper<Optuna.Trial>()
|
||||
@@ -99,5 +100,11 @@ export const TrialTable: FC<{
|
||||
}
|
||||
}
|
||||
|
||||
return <DataGrid data={trials} columns={columns} />
|
||||
return (
|
||||
<DataGrid
|
||||
data={trials}
|
||||
columns={columns}
|
||||
initialRowsPerPage={initialRowsPerPage}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user