-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dg): show numbers of rows pagination
- Loading branch information
Showing
12 changed files
with
143 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 15 additions & 7 deletions
22
packages/pluggableWidgets/datagrid-web/src/utils/useShowPagination.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
import { useMemo } from "react"; | ||
import { useMemo, useEffect } from "react"; | ||
import { PaginationEnum, ShowPagingButtonsEnum } from "../../typings/DatagridProps"; | ||
|
||
interface ShowPaginationProps { | ||
pagination: PaginationEnum; | ||
showPagingButtons: ShowPagingButtonsEnum; | ||
showPagingButtonsOrRows: ShowPagingButtonsEnum | boolean; | ||
totalCount?: number; | ||
limit: number; | ||
requestTotalCount: (needTotalCount: boolean) => void; | ||
} | ||
|
||
export const useShowPagination = (props: ShowPaginationProps): boolean => { | ||
const { pagination, showPagingButtons, totalCount, limit } = props; | ||
const { pagination, showPagingButtonsOrRows, totalCount, limit, requestTotalCount } = props; | ||
|
||
useEffect(() => { | ||
if (pagination !== "buttons" && showPagingButtonsOrRows) { | ||
requestTotalCount(true); | ||
} | ||
}, [pagination]); | ||
|
||
return useMemo(() => { | ||
return ( | ||
pagination === "buttons" && | ||
(showPagingButtons === "always" || | ||
(showPagingButtons === "auto" && (totalCount ? totalCount > limit : false))) | ||
showPagingButtonsOrRows === true || | ||
showPagingButtonsOrRows === "always" || | ||
(showPagingButtonsOrRows === "auto" && (totalCount ? totalCount > limit : false)) | ||
); | ||
}, [pagination, showPagingButtons, totalCount, limit]); | ||
}, [pagination, showPagingButtonsOrRows, totalCount, limit]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.