Skip to content

Pagination ​

The pagination bar shows the total number of rows, the page buttons and, with pageSizeOptions, a page size dropdown.

vue
<template>
  <VTable
    v-model:currentPage="page"
    v-model:itemsPerPage="size"
    :columns="columns"
    :data="products"
    :pageSizeOptions="[5, 10, 25]"
    clientSide
  />
  <p class="demo-log">page {{ page }}, {{ size }} rows per page</p>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { VTable, type Column } from "v-table-system";
import { products } from "./data";

const page = ref(1);
const size = ref(5);

const columns: Column[] = [
  { key: "id", label: "ID" },
  { key: "name", label: "Name" },
  { key: "category", label: "Category" },
];
</script>

Props ​

PropDescription
currentPageThe active page, starting at 1. Works with v-model:currentPage.
itemsPerPageRows per page. Works with v-model:itemsPerPage.
pageSizeOptionsSizes offered in the dropdown, for example [10, 25, 50]. No dropdown when left out.
totalItemsTotal number of rows on the server. Not needed with clientSide.
showPaginationSet to false to hide the bar. With clientSide all rows are then shown.

Events ​

EventPayloadWhen
changePagepage numberThe user picks another page.
changeItemsPerPagepage sizeThe user picks another page size. The table also goes back to page 1.

Set itemsPerPage for server-side tables

Without clientSide, itemsPerPage defaults to 1, so the number of pages equals totalItems. Always pass itemsPerPage together with totalItems.

With clientSide it defaults to the first entry of pageSizeOptions, or 10.

totalPages

totalPages is the old name of totalItems. Despite its name it has always been the number of rows, not pages. It still works.

Released under the Apache-2.0 License.