Skip to content

Commit

Permalink
Fix pagination issue in grid view
Browse files Browse the repository at this point in the history
Fixes #111
  • Loading branch information
itsmemyk08 committed Jun 8, 2023
1 parent 94e52db commit 27341f8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions axelor-front/src/views/grid/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ function GridInner(props: ViewProps<GridView>) {

const canPrev = offset > 0;
const canNext = offset + limit < totalCount;
const minPage = 1;
const maxPage = Math.ceil(totalCount / limit);
const hasRowSelected = !!selectedRows?.length;
const currentPage = useMemo(() => {
const hasPageSet = pageSetRef.current;
Expand Down Expand Up @@ -596,11 +598,11 @@ function GridInner(props: ViewProps<GridView>) {
canNext,
onPrev: () =>
switchTo("grid", {
route: { id: String(currentPage - 1) },
route: { id: String(Math.max(minPage, currentPage - 1)) },
}),
onNext: () =>
switchTo("grid", {
route: { id: String(currentPage + 1) },
route: { id: String(Math.min(maxPage, currentPage + 1)) },
}),
text: () => <PageText dataStore={dataStore} />,
}}
Expand Down

0 comments on commit 27341f8

Please sign in to comment.