Vuetable-2: Vue 2.x Datatable Component

1.7.5 · active · verified Sun Apr 19

Vuetable-2 is a flexible datatable component designed for Vue 2.x applications, providing robust capabilities for displaying and interacting with tabular data. The package is currently at its stable version 1.7.5, with an active development branch (`v2.0.0-beta`) introducing features like SSR support and a more modular field component system. While a strict release cadence is not followed, updates are delivered to enhance features and resolve issues. Its key differentiators include comprehensive API-mode handling, customizable field definitions, integrated pagination (including zero-based options in v2), a rich event system for interaction, and support for fixed table headers, making it adaptable for complex data presentation scenarios. It simplifies data management tasks in Vue 2.x SPAs.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates basic setup of `vuetable-2` with API-driven data, including a standard pagination component. It defines fields, connects to a mock API endpoint, and handles pagination data and page changes through events. This snippet assumes a basic Vue 2 setup and a compatible CSS framework.

import Vue from 'vue';
import Vuetable from 'vuetable-2';
import VuetablePagination from 'vuetable-2/src/components/VuetablePagination';

new Vue({
  el: '#app',
  components: { Vuetable, VuetablePagination },
  data: {
    fields: [
      { name: 'id', title: 'ID' },
      { name: 'name', title: 'Name' },
      { name: 'email', title: 'Email' },
    ],
    apiUrl: 'https://example.com/api/users',
    css: {
      table: 'table table-striped table-bordered',
      // ... other css classes as per documentation
    },
  },
  template: `
    <div>
      <vuetable ref="vuetable"
        :api-url="apiUrl"
        :fields="fields"
        pagination-path="pagination"
        @vuetable:pagination-data="onPaginationData"
      ></vuetable>
      <vuetable-pagination ref="pagination"
        @vuetable:change-page="onChangePage"
      ></vuetable-pagination>
    </div>
  `,
  methods: {
    onPaginationData(paginationData) {
      this.$refs.pagination.setPaginationData(paginationData);
    },
    onChangePage(page) {
      this.$refs.vuetable.changePage(page);
    },
  },
});

view raw JSON →