[Table] Show total pages if client-side paginaiton

This commit is contained in:
navaneeth 2021-05-02 19:30:58 +05:30
parent 1fdbac3f2d
commit 4f48b6b580
2 changed files with 16 additions and 6 deletions

View file

@ -5,7 +5,8 @@ export const Pagination = function Pagination({
serverSide,
autoGotoPage,
autoCanNextPage,
autoPageCount
autoPageCount,
autoPageOptions
}) {
const [pageIndex, setPageIndex] = useState(1);
const [pageCount, setPageCount] = useState(autoPageCount);
@ -45,14 +46,22 @@ export const Pagination = function Pagination({
{'<'}
</button>{' '}
<small className="p-1 mx-2">
<strong>
{pageIndex}
</strong>
{serverSide &&
<strong>
{pageIndex}
</strong>
}
{!serverSide &&
<strong>
{pageIndex} of {autoPageOptions.length}
</strong>
}
</small>
<button
className="btn btn-light btn-sm"
onClick={() => goToNextPage()}
disabled={!autoCanNextPage}
disabled={!autoCanNextPage && !serverSide}
>
{'>'}
</button>{' '}

View file

@ -367,7 +367,7 @@ export function Table({
columns,
data,
defaultColumn,
initialState: { pageIndex: 0 },
initialState: { pageIndex: 0, pageSize: serverSidePagination ? -1 : 10}, // pageSize should be unset if server-side pagination is enabled
pageCount: -1,
manualPagination: false,
getExportFileBlob
@ -515,6 +515,7 @@ export function Table({
autoGotoPage={gotoPage}
autoCanNextPage={canNextPage}
autoPageCount={pageCount}
autoPageOptions={pageOptions}
onPageIndexChanged={onPageIndexChanged}
/>
</div>