usePagination
DataTable
stable
Suite of three pagination helpers for OrigamDataTable: createPagination initialises page and itemsPerPage refs from props; providePagination computes derived state (startIndex, stopIndex, pageCount) and provides it to children; usePagination injects the provided pagination context. A fourth helper usePaginatedItems slices the items array for the current page.
API
Signature
Signature TypeScript complète extraite du fichier du composable.
Interfaces consommées
IDataTablePaginationProps
IDataTableProvidePagination
IDataTableGroup
API
Paramètres
Paramètres d'entrée acceptés par ce composable.
- propsrequisIDataTablePaginationProps
- Component props containing page and itemsPerPage (for createPagination).
- options.pagerequisRef<number>
- Active page (1-based). Auto-clamped to [1, pageCount] when itemsLength or itemsPerPage changes.
- options.itemsPerPagerequisRef<number>
- Rows per page. -1 = show all.
- options.itemsLengthrequisRef<number>
- Total number of items (server-side count or items.length for client-side).
API
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- page
- Current page, two-way bound via useVModel.
- itemsPerPage
- Rows per page, two-way bound.
- startIndex
- Inclusive start index in the full items array for the active page.
- stopIndex
- Exclusive stop index. slice(startIndex, stopIndex) gives the current page.
- pageCount
- Total number of pages. Always at least 1. Equals 1 when itemsPerPage is -1.
- nextPage
- Advances to the next page, clamped to pageCount.
- prevPage
- Goes back one page, minimum 1.
- setPage
- Jumps to an arbitrary page, clamped to [1, pageCount].
- setItemsPerPage
- Changes the page size and resets to page 1.
Usage
Exemples
Extraits de code prêts à coller.
Client-side paginated table
Custom pagination footer